結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | 👑 hos.lyric |
提出日時 | 2020-12-03 00:42:30 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,582 bytes |
コンパイル時間 | 2,138 ms |
コンパイル使用メモリ | 174,996 KB |
実行使用メモリ | 25,964 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-06-22 10:12:09 |
合計ジャッジ時間 | 25,985 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
24,812 KB |
testcase_01 | AC | 23 ms
25,196 KB |
testcase_02 | AC | 23 ms
25,220 KB |
testcase_03 | AC | 24 ms
24,964 KB |
testcase_04 | AC | 23 ms
25,220 KB |
testcase_05 | AC | 23 ms
25,220 KB |
testcase_06 | AC | 22 ms
24,964 KB |
testcase_07 | AC | 23 ms
24,580 KB |
testcase_08 | AC | 24 ms
24,836 KB |
testcase_09 | AC | 23 ms
24,836 KB |
testcase_10 | AC | 23 ms
24,964 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 23 ms
25,580 KB |
testcase_14 | WA | - |
testcase_15 | AC | 24 ms
24,556 KB |
testcase_16 | AC | 23 ms
24,812 KB |
testcase_17 | AC | 22 ms
24,812 KB |
testcase_18 | WA | - |
testcase_19 | AC | 22 ms
25,708 KB |
testcase_20 | WA | - |
testcase_21 | AC | 24 ms
25,196 KB |
testcase_22 | AC | 23 ms
24,556 KB |
testcase_23 | AC | 23 ms
25,196 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 24 ms
25,196 KB |
testcase_29 | AC | 24 ms
25,324 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 24 ms
25,196 KB |
testcase_34 | WA | - |
testcase_35 | AC | 24 ms
25,196 KB |
testcase_36 | AC | 24 ms
24,812 KB |
testcase_37 | AC | 24 ms
25,580 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 23 ms
24,556 KB |
testcase_43 | AC | 23 ms
25,196 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | AC | 31 ms
25,196 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | AC | 34 ms
25,196 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | AC | 71 ms
25,196 KB |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | AC | 106 ms
24,940 KB |
testcase_98 | AC | 104 ms
25,196 KB |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | WA | - |
testcase_104 | WA | - |
testcase_105 | WA | - |
testcase_106 | AC | 103 ms
25,196 KB |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | WA | - |
testcase_117 | WA | - |
testcase_118 | WA | - |
testcase_119 | AC | 112 ms
25,324 KB |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | WA | - |
ソースコード
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } int N; debug { int[] A; } alias Pair = Tuple!(int, "p", int, "q"); Pair Ask(int i, int j) { writefln("? %s %s", i + 1, j + 1); stdout.flush; int p, q; debug { p = A[i] / N - A[j] / N; q = A[i] % N - A[j] % N; if (p > q) { swap(p, q); } } else { p = readInt(); q = readInt(); } return Pair(p, q); } void main() { N = readInt(); debug { A = new int[N^^2 - N]; foreach (i; 0 .. N^^2 - N) { A[i] = readInt(); } } auto ans = new int[N^^2 - N]; alias Entry = Tuple!(Pair, "val", int, "id"); Entry[] es; foreach (i; 1 .. N^^2 - N) { const res = Ask(i, 0); es ~= Entry(res, i); } const esLen = cast(int)(es.length); es.sort; Pair mn = Pair(0, 0); Pair mx = Pair(0, 0); foreach (ref e; es) { if (mn.p + mn.q > e.val.p + e.val.q) mn = e.val; if (mx.p + mx.q < e.val.p + e.val.q) mx = e.val; } debug { writeln("mn = ", mn); writeln("mx = ", mx); } int[] a0s; foreach (s; 0 .. 2) foreach (t; 0 .. 2) { const x0mn = 1 - (s ? mn.q : mn.p); const y0mn = 0 - (s ? mn.p : mn.q); const x0mx = N - 1 - (t ? mx.q : mx.p); const y0mx = N - 1 - (t ? mx.p : mx.q); debug { writefln("(%s, %s), (%s, %s)", x0mn, y0mn, x0mx, y0mx); } if (x0mn == x0mx && y0mn == y0mx) { a0s ~= x0mn * N + y0mn; } } a0s = a0s.sort.uniq.array; assert(a0s.length == 1); ans[0] = a0s[0]; for (int x = 0, y; x < esLen; x = y) { for (y = x; y < esLen && es[x].val == es[y].val; ++y) {} const x1 = ans[0] / N + es[x].val.p; const y1 = ans[0] % N + es[x].val.q; const x2 = ans[0] / N + es[x].val.q; const y2 = ans[0] % N + es[x].val.p; if (y - x == 1) { const i = es[x].id; if (1 <= x1 && x1 <= N - 1 && 0 <= y1 && y1 <= N - 1) { ans[i] = x1 * N + y1; } else { ans[i] = x2 * N + y2; } } else if (y - x == 2) { const i = es[x].id; const j = es[x + 1].id; const res = Ask(j, i); if ((x2 - x1 == res.p && y2 - y1 == res.q) || (x2 - x1 == res.q && y2 - y1 == res.p)) { ans[i] = x1 * N + y1; ans[j] = x2 * N + y2; } else { ans[i] = x2 * N + y2; ans[j] = x1 * N + y1; } } else { for(;;){} assert(false); } } write("!"); foreach (i; 0 .. N^^2 - N) { write(" ", ans[i]); } writeln; stdout.flush; }