結果
問題 | No.2085 Directed Complete Graph |
ユーザー | fairy_lettuce |
提出日時 | 2022-09-27 00:31:01 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 206 ms / 2,000 ms |
コード長 | 9,444 bytes |
コンパイル時間 | 7,056 ms |
コンパイル使用メモリ | 168,036 KB |
実行使用メモリ | 50,172 KB |
平均クエリ数 | 2533.76 |
最終ジャッジ日時 | 2024-06-02 00:35:03 |
合計ジャッジ時間 | 11,126 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
49,160 KB |
testcase_01 | AC | 69 ms
49,156 KB |
testcase_02 | AC | 197 ms
50,172 KB |
testcase_03 | AC | 187 ms
49,648 KB |
testcase_04 | AC | 203 ms
49,652 KB |
testcase_05 | AC | 133 ms
49,540 KB |
testcase_06 | AC | 135 ms
49,540 KB |
testcase_07 | AC | 205 ms
49,796 KB |
testcase_08 | AC | 168 ms
49,608 KB |
testcase_09 | AC | 201 ms
49,508 KB |
testcase_10 | AC | 204 ms
49,804 KB |
testcase_11 | AC | 201 ms
49,804 KB |
testcase_12 | AC | 206 ms
50,056 KB |
testcase_13 | AC | 205 ms
49,676 KB |
testcase_14 | AC | 200 ms
49,800 KB |
testcase_15 | AC | 70 ms
49,284 KB |
testcase_16 | AC | 69 ms
49,668 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (84 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) /home/judge/data/code/Main.cs(17,12): warning CS0169: フィールド 'SolverA.hasPath' は使用されていません [/home/judge/data/code/main.csproj] main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Threading; namespace CpLibrary.Contest { public class SolverA : SolverBase { Scanner sr; bool hasMultipleTestcases = false; bool IsLocal { get; set; } int count = 0; bool[][] hasPath; public override void Solve() { var n = sr.ReadInt(); //var m = sr.ReadInt(); //var p = sr.ReadTupleArray<int, int>(m); //for (int i = 0; i < m; i++) //{ // p[i] = (p[i].Item1 - 1, p[i].Item2 - 1); //} //hasPath = CreateArray(n, n, (i, j) => false); //for (int i = 0; i < m; i++) //{ // hasPath[p[i].Item1][p[i].Item2] = true; //} Solve(n); } public void Solve(int n) { var ans = new List<int> { 0 }; for (int i = 1; i < n; i++) { var ok = -1; var ng = i; while (ng - ok > 1) { var mid = ok + (ng - ok) / 2; var val = Query(ans[mid], i); if (val == 1) ok = mid; else ng = mid; } ans.Insert(ok + 1, i); } Answer(ans); } public int Query(int a, int b) { count++; Console.WriteLine($"? {a + 1} {b + 1}"); Console.Out.Flush(); var value = sr.ReadInt(); return value; //return hasPath[a][b] ? 1 : 0; } public void Answer(List<int> list) { Console.WriteLine("!"); Console.WriteLine(list.Count - 1); Console.WriteLine(list.Select(p => p + 1).Join(" ")); //for (int i = 0; i < list.Count - 1; i++) //{ // if (!hasPath[list[i]][list[i + 1]]) Console.WriteLine($"yabai {list[i]} {list[i + 1]}"); //} } public void Init() { /* * Write your init code here if you need! */ } public SolverA(Scanner sr, bool isLocal = false) { this.sr = sr; this.IsLocal = isLocal; } public override void Run() { Init(); var _t = 1; if (hasMultipleTestcases) _t = sr.ReadInt(); while (_t-- > 0) Solve(); } } public static class ProgramA { private static bool StartsOnThread = true; public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var sr = new Scanner(new StreamReader(Console.OpenStandardInput())); var solver = new SolverA(sr); if (StartsOnThread) { var thread = new Thread(new ThreadStart(() => solver.Run()), 1 << 27); thread.Start(); thread.Join(); } else solver.Run(); Console.Out.Flush(); } public static void Expand() => SourceExpander.Expander.Expand(); } } #region Expanded by https://github.com/naminodarie/SourceExpander namespace CpLibrary { public static class Extention { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); public static string Join<T>(this IEnumerable<T> x, char separator) => string.Join(separator, x); public static int UpperBound<T>(this IList<T> list, T value) => list.BinarySearch(value, true, 0, list.Count, Comparer<T>.Default); public static int LowerBound<T>(this IList<T> list, T value) => list.BinarySearch(value, false, 0, list.Count, Comparer<T>.Default); public static int BinarySearch<T>(this IList<T> list, T value, bool isUpperBound, int index, int length, Comparer<T> comparer) { var ng = index - 1; var ok = index + length; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2; var res = comparer.Compare(list[mid], value); if (res < 0 || (isUpperBound && res == 0)) ng = mid; else ok = mid; } return ok; } public static bool Chmax<T>(ref this T a, T b) where T : struct, IComparable<T> { if (a.CompareTo(b) >= 0) return false; a = b; return true; } public static bool Chmin<T>(ref this T a, T b) where T : struct, IComparable<T> { if (a.CompareTo(b) <= 0) return false; a = b; return true; } } } namespace CpLibrary { public class Scanner { public StreamReader sr { get; private set; } string[] str; int index; char[] separators; public Scanner(StreamReader sr, char[] separators) { this.sr = sr; this.separators = separators; str = new string[0]; index = 0; } public Scanner(StreamReader sr) : this(sr, new char[]{' '}) { } public Scanner() : this(new StreamReader(Console.OpenStandardInput()), new char[]{' '}) { } public string Read() { if (index < str.Length) return str[index++]; string s; do s = sr.ReadLine(); while (s == ""); str = s.Split(separators, StringSplitOptions.RemoveEmptyEntries); index = 0; return str[index++]; } public string ReadString() => Read(); public string[] ReadStringArray(int n) { var arr = new string[n]; for (int i = 0; i < n; i++) { arr[i] = ReadString(); } return arr; } public int ReadInt() => int.Parse(ReadString()); public int[] ReadIntArray(int n) => ReadValueArray<int>(n); public long ReadLong() => long.Parse(ReadString()); public long[] ReadLongArray(int n) => ReadValueArray<long>(n); public double ReadDouble() => double.Parse(ReadString()); public double[] ReadDoubleArray(int n) => ReadValueArray<double>(n); public BigInteger ReadBigInteger() => BigInteger.Parse(ReadString()); public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() => (ReadValue<T1>(), ReadValue<T2>()); public (T1, T2, T3) ReadValue<T1, T2, T3>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>()); public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>()); public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>()); public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>(), ReadValue<T6>()); public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>(), ReadValue<T6>(), ReadValue<T7>()); public T1[] ReadValueArray<T1>(int n) { var arr = new T1[n]; for (int i = 0; i < n; i++) { arr[i] = ReadValue<T1>(); } return arr; } public (T1[], T2[]) ReadValueArray<T1, T2>(int n) { var(v1, v2) = (new T1[n], new T2[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i]) = ReadValue<T1, T2>(); } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int n) { var(v1, v2, v3) = (new T1[n], new T2[n], new T3[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i]) = ReadValue<T1, T2, T3>(); } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int n) { var(v1, v2, v3, v4) = (new T1[n], new T2[n], new T3[n], new T4[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i]) = ReadValue<T1, T2, T3, T4>(); } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int n) { var(v1, v2, v3, v4, v5) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i]) = ReadValue<T1, T2, T3, T4, T5>(); } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int n) { var(v1, v2, v3, v4, v5, v6) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n], new T6[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i], v6[i]) = ReadValue<T1, T2, T3, T4, T5, T6>(); } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int n) { var(v1, v2, v3, v4, v5, v6, v7) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n], new T6[n], new T7[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i], v6[i], v7[i]) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); } return (v1, v2, v3, v4, v5, v6, v7); } public (T1, T2)[] ReadTupleArray<T1, T2>(int n) { var ret = new (T1, T2)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2>(); } return ret; } public (T1, T2, T3)[] ReadTupleArray<T1, T2, T3>(int n) { var ret = new (T1, T2, T3)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3>(); } return ret; } public (T1, T2, T3, T4)[] ReadTupleArray<T1, T2, T3, T4>(int n) { var ret = new (T1, T2, T3, T4)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4>(); } return ret; } public (T1, T2, T3, T4, T5)[] ReadTupleArray<T1, T2, T3, T4, T5>(int n) { var ret = new (T1, T2, T3, T4, T5)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5>(); } return ret; } public (T1, T2, T3, T4, T5, T6)[] ReadTupleArray<T1, T2, T3, T4, T5, T6>(int n) { var ret = new (T1, T2, T3, T4, T5, T6)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5, T6>(); } return ret; } public (T1, T2, T3, T4, T5, T6, T7)[] ReadTupleArray<T1, T2, T3, T4, T5, T6, T7>(int n) { var ret = new (T1, T2, T3, T4, T5, T6, T7)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); } return ret; } } } namespace CpLibrary { public interface ISolver { public void Solve(); public void Run(); } public abstract class SolverBase : ISolver { public abstract void Solve(); public abstract void Run(); } } namespace SourceExpander{public class Expander{[Conditional("EXP")]public static void Expand(string inputFilePath=null,string outputFilePath=null,bool ignoreAnyError=true){}public static string ExpandString(string inputFilePath=null,bool ignoreAnyError=true){return "";}}} #endregion Expanded by https://github.com/naminodarie/SourceExpander