/// <summary> /// /// </summary> /// <param name="video"></param> /// <param name="audio"></param> /// <param name="dstFile"></param> /// <param name="e"></param> /// <returns>如果混流顺利完成,返回true;如果被用户中止或在过程中出错,返回false。</returns> private bool Mux(JobItem jobItem, DoWorkEventArgs e) { try { jobItem.Event = JobEvent.Muxing; jobItem.ProcessMuxing(); return(this.ProcessingReport(jobItem, jobItem.MuxingInfo, e)); } catch (FormatNotSupportedException) { MessageBox.Show("合成MP4失败。可能源媒体流中有不支持的格式。", "合成失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.SetJobEventAndReportProgress(jobItem, JobEvent.Error); return(false); } catch (FFmpegBugException) { MessageBox.Show("合成MP4失败。这是由于FFmpeg的一些Bug, 对某些流无法使用复制。", "合成失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.SetJobEventAndReportProgress(jobItem, JobEvent.Error); return(false); } finally { if ((jobItem.JobConfig.AudioMode == StreamProcessMode.Encode) && !MyIO.IsSameFile(jobItem.MuxingInfo.AudioFile, jobItem.DestFile)) { File.Delete(jobItem.MuxingInfo.AudioFile); } } }
public string Solve(MyIO io) { int N = io.NextInt; List <int> l = new List <int>(); for (int i = 0; i < N; i++) { l.Add(io.NextInt); } int R = 0; for (int i = 0; i < N; i++) { int minval = (int)(2 * 1e9), pos = -1; for (int j = 0; j < l.Count; j++) { if (l[j] < minval) { minval = l[j]; pos = j; } } R += Math.Min(pos, N - 1 - i - pos); List <int> ll = new List <int>(); for (int j = 0; j < l.Count; j++) { if (j != pos) { ll.Add(l[j]); } } l = ll; } return(R.ToString()); }
private void DrawKey() // 快捷键 { MyCreate.Box(() => { m_Tools.TextText_BL("Ctrl + W", "复制 UGUI 名到剪切版", -50); m_Tools.Text_G("使用它,再也不用烦找名字的痛苦了"); }); AddSpace(); MyCreate.Box(() => { m_Tools.Text_Y("先点击选择多个图片,给它们添加前缀"); Texture2D[] texs = Selection.GetFiltered <Texture2D>(SelectionMode.Assets); bool isCanClick = (null == texs || texs.Length <= 0); GUI.enabled = !isCanClick; MyCreate.Button(" 一键添加前缀", () => { foreach (Texture2D texture2 in texs) { string assetPath = AssetDatabase.GetAssetPath(texture2); string fullPath = MyAssetUtil.GetFullPath(assetPath); string fileName = MyAssetUtil.GetFileNameByFullName(fullPath); MyIO.FileRename(fullPath, "EX_" + fileName); } AssetDatabase.Refresh(); }); GUI.enabled = true; }); }
public override bool ConfigWavelength() { bool flag = false; flag = MyIO.WriteString(":INP" + PowerMeterSlot + ":WAV " + PowerMeterWavelength + "nm"); logger.AdapterLogString(0, "AttSlot is" + PowerMeterSlot + "Wavelength is" + PowerMeterWavelength + "nm"); return(flag); }
public void Run() { bool quit = false; MyIO.ClearScreen(); while (quit == false) { quit = MainMenu(); } }
public void ReadDay1TestDataIntsTest() { var intPuzzleInput = MyIO.ReadIntsFromFile(2021, 1, 1, true); var intTestData = new List <int>() { 199, 200, 208, 210, 200, 207, 240, 269, 260, 263 }; Assert.That(intPuzzleInput, Is.EquivalentTo(intTestData)); }
public void ReadDay1TestDataStringsTest() { var stringPuzzleInput = MyIO.ReadStringsFromFile(2021, 1, 1, true); var stringTestData = new List <string>() { "199", "200", "208", "210", "200", "207", "240", "269", "260", "263" }; Assert.That(stringPuzzleInput, Is.EquivalentTo(stringTestData)); }
public string Solve(MyIO io) { long res = 0; int N = io.NextInt; long P = io.NextLong; long res1 = R1(N, P); long res2 = R2(N, P); return(res2.ToString() + " " + res1.ToString() + '\n'); }
public void ReadDay3TestDataStringsTest() { var stringPuzzleInput = MyIO.ReadStringsFromFile(2021, 3, 1, true); var stringTestData = new List <string>() { "00100", "11110", "10110", "10111", "10101", "01111", "00111", "11100", "10000", "11001", "00010", "01010" }; Assert.That(stringPuzzleInput, Is.EquivalentTo(stringTestData)); }
public void ReadDay2TestDataStringsTest() { var stringPuzzleInput = MyIO.ReadStringsFromFile(2021, 2, 1, true); var stringTestData = new List <string>() { "forward 5", "down 5", "forward 8", "up 3", "down 8", "forward 2" }; Assert.That(stringPuzzleInput, Is.EquivalentTo(stringTestData)); }
public string Solve(MyIO io) { int R = 0; int N = io.NextInt, M = io.NextInt; List <string> l = new List <string>(); for (int i = 0; i < N; i++) { l.Add(io.NextString); } int k = 1; for (int i = 0; i < N; i++) { k *= M; } int max = 0; R = 0; for (int i = 0; i < k; i++) { List <string>[] ll = new List <string> [M]; for (int j = 0; j < M; j++) { ll[j] = new List <string>(); } int x = i; for (int j = 0; j < N; j++) { int t = x % M; x /= M; ll[t].Add(l[j]); } int q = 0; for (int j = 0; j < M; j++) { q += cal(ll[j]); } if (max < q) { max = q; R = 1; } else if (max == q) { R++; } } return(max.ToString() + " " + R.ToString()); }
public string Solve(MyIO io) { int N = io.NextInt, L = io.NextInt; List <long> l = new List <long>(), l2 = new List <long>(); for (int i = 0; i < N; i++) { l.Add(convert(io.NextString)); } for (int i = 0; i < N; i++) { l2.Add(convert(io.NextString)); } bool ok = false; l.Sort(); int R = 9999; for (int i = 0; i < N; i++) { List <long> ll2 = new List <long>(); for (int j = 0; j < N; j++) { ll2.Add(l2[j] ^ (l[0] ^ l2[i])); } ll2.Sort(); bool o1 = true; for (int j = 0; j < N; j++) { if (ll2[j] != l[j]) { o1 = false; } } if (o1) { int r = 0; long Z = l[0] ^ l2[i]; for (int j = 0; j < 64; j++) { if ((Z & (1L << j)) != 0) { r++; } } R = Math.Min(R, r); } } if (R == 9999) { return("NOT POSSIBLE"); } return(R.ToString()); }
private bool ConfigureDataLevelMode(byte elecLevelMode)//0=VARiable,1=NECL,2=PCML,3=NCML,4=SCFL,5=LVPecl,6=LVDS200,7=LVDS400 { string strElecLevelMode; switch (elecLevelMode) { case 0: strElecLevelMode = "VARiable"; break; case 1: strElecLevelMode = "NECL"; break; case 2: strElecLevelMode = "PCML"; break; case 3: strElecLevelMode = "NCML"; break; case 4: strElecLevelMode = "SCFL"; break; case 5: strElecLevelMode = "LVPecl"; break; case 6: strElecLevelMode = "LVDS200"; break; case 7: strElecLevelMode = "LVDS400"; break; default: strElecLevelMode = "VARiable"; break; } try { logger.AdapterLogString(0, "DataLevelMode is" + strElecLevelMode); return(MyIO.WriteString(":OUTPut:DATA:LEVel DATA," + strElecLevelMode)); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
private bool ConfigureSlot(byte slot) { try { logger.AdapterLogString(0, "slot is" + slot); return(MyIO.WriteString(":MODule:ID " + slot.ToString() + "\n")); } catch (Exception error) { throw error; } }
private bool EdGatingStart() { try { return(MyIO.WriteString(":SENSe:MEASure:STARt")); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
private bool EdAutoSearchSetAll() { try { return(MyIO.WriteString(":SENSe:MEASure:ASEarch:SLASet")); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public bool ReSet() { if (MyIO.WriteString("*RST")) { Thread.Sleep(3000); return(true); } else { return(false); } }
override public bool CDISplay() { try { return(MyIO.WriteString(":CDISplay")); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override bool CLS() { try { return(MyIO.WriteString("*CLS")); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
override public bool AutoScale() { try { return(MyIO.WriteString(":AUToscale")); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override bool lockHeadPosition(byte Switch)//1 UP,0 DOWN { try { return(MyIO.WriteString("HDLK " + Switch.ToString())); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override bool SetPositionUPDown(string position)//0 UP,1 DOWN { try { return(MyIO.WriteString("HEAD " + position)); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override bool SensorType()//0 No Sensor,1 T,2 k,3 rtd,4 diode { try { return(MyIO.WriteString("DUTM " + Sensor)); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override bool DUTControlModeOnOFF(byte Switch)//1 ON,0 OFF { try { return(MyIO.WriteString("DUTM " + Switch.ToString())); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override byte[] FpgaIICWrtie(int regAddress, byte[] dataToWrite) { try { return(MyIO.FpgaIICWrtie(deviceIndex, regAddress, 0xC2, dataToWrite)); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(new byte[16]); } }
public override byte[] FpgaIICRead(int regAddress, int readLength) { try { return(MyIO.FpgaIICRead(deviceIndex, regAddress, 0xC2, readLength)); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(new byte[16]); } }
public override bool FpgaReset(byte operate) {//0 reset,1 release reset try { MyIO.FpgaInrush(deviceIndex, false, 0xC7, operate); return(true); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
static void Main(string[] args) { MyIO io = new MyIO(new StreamReader("in.txt")); int caseCount = io.NextInt; Solver solve = new Solver(); for (int i = 0; i < caseCount; i++) { string res = solve.Solve(io); io.Write("Case #{0}: {1}", i + 1, res); } io.Flush(); }
public override bool FpgaResetTimeSet(double delaytime) { try { MyIO.FpgaResetTimeSet(deviceIndex, false, 0xCC, delaytime); return(true); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }
public override bool FpgaTxDisable(byte operate) {//0 off,1 on try { MyIO.FpgaInrush(deviceIndex, false, 0xC3, operate); return(true); } catch (Exception error) { logger.AdapterLogString(3, error.ToString()); return(false); } }