結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | trineutron |
提出日時 | 2020-12-03 03:08:17 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 2,481 bytes |
コンパイル時間 | 2,560 ms |
コンパイル使用メモリ | 220,296 KB |
実行使用メモリ | 25,452 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 08:21:14 |
合計ジャッジ時間 | 16,573 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
25,436 KB |
testcase_01 | AC | 23 ms
24,940 KB |
testcase_02 | AC | 23 ms
24,836 KB |
testcase_03 | AC | 23 ms
25,220 KB |
testcase_04 | AC | 25 ms
25,220 KB |
testcase_05 | AC | 23 ms
25,220 KB |
testcase_06 | AC | 23 ms
25,220 KB |
testcase_07 | AC | 23 ms
24,580 KB |
testcase_08 | AC | 24 ms
24,824 KB |
testcase_09 | AC | 24 ms
25,220 KB |
testcase_10 | AC | 24 ms
24,580 KB |
testcase_11 | AC | 23 ms
24,836 KB |
testcase_12 | AC | 23 ms
24,836 KB |
testcase_13 | AC | 23 ms
25,196 KB |
testcase_14 | AC | 23 ms
25,452 KB |
testcase_15 | AC | 22 ms
25,088 KB |
testcase_16 | AC | 23 ms
25,324 KB |
testcase_17 | AC | 24 ms
25,196 KB |
testcase_18 | AC | 23 ms
24,812 KB |
testcase_19 | AC | 22 ms
24,940 KB |
testcase_20 | AC | 24 ms
24,556 KB |
testcase_21 | AC | 23 ms
24,544 KB |
testcase_22 | AC | 23 ms
24,544 KB |
testcase_23 | AC | 24 ms
24,556 KB |
testcase_24 | AC | 23 ms
24,940 KB |
testcase_25 | AC | 24 ms
24,812 KB |
testcase_26 | AC | 23 ms
24,940 KB |
testcase_27 | AC | 23 ms
24,812 KB |
testcase_28 | AC | 23 ms
25,196 KB |
testcase_29 | AC | 24 ms
24,812 KB |
testcase_30 | AC | 24 ms
25,196 KB |
testcase_31 | AC | 24 ms
24,812 KB |
testcase_32 | AC | 24 ms
25,184 KB |
testcase_33 | AC | 24 ms
25,040 KB |
testcase_34 | AC | 25 ms
24,812 KB |
testcase_35 | AC | 24 ms
24,556 KB |
testcase_36 | AC | 24 ms
24,940 KB |
testcase_37 | AC | 24 ms
24,812 KB |
testcase_38 | AC | 24 ms
24,812 KB |
testcase_39 | AC | 26 ms
24,940 KB |
testcase_40 | AC | 24 ms
24,812 KB |
testcase_41 | AC | 24 ms
24,940 KB |
testcase_42 | AC | 25 ms
24,812 KB |
testcase_43 | AC | 25 ms
25,100 KB |
testcase_44 | AC | 25 ms
25,196 KB |
testcase_45 | AC | 26 ms
24,812 KB |
testcase_46 | AC | 26 ms
25,196 KB |
testcase_47 | AC | 27 ms
25,196 KB |
testcase_48 | AC | 28 ms
24,556 KB |
testcase_49 | AC | 29 ms
25,196 KB |
testcase_50 | AC | 30 ms
25,196 KB |
testcase_51 | AC | 32 ms
24,812 KB |
testcase_52 | AC | 33 ms
24,556 KB |
testcase_53 | AC | 36 ms
24,940 KB |
testcase_54 | AC | 33 ms
24,940 KB |
testcase_55 | AC | 37 ms
25,196 KB |
testcase_56 | AC | 38 ms
24,940 KB |
testcase_57 | AC | 39 ms
25,196 KB |
testcase_58 | AC | 41 ms
24,556 KB |
testcase_59 | AC | 40 ms
24,812 KB |
testcase_60 | AC | 48 ms
24,940 KB |
testcase_61 | AC | 50 ms
24,556 KB |
testcase_62 | AC | 51 ms
24,812 KB |
testcase_63 | AC | 55 ms
24,812 KB |
testcase_64 | AC | 52 ms
24,940 KB |
testcase_65 | AC | 55 ms
24,556 KB |
testcase_66 | AC | 61 ms
24,940 KB |
testcase_67 | AC | 62 ms
24,556 KB |
testcase_68 | AC | 62 ms
25,424 KB |
testcase_69 | AC | 66 ms
24,940 KB |
testcase_70 | AC | 66 ms
24,940 KB |
testcase_71 | AC | 69 ms
24,556 KB |
testcase_72 | AC | 69 ms
24,812 KB |
testcase_73 | AC | 68 ms
24,556 KB |
testcase_74 | AC | 80 ms
24,812 KB |
testcase_75 | AC | 74 ms
24,812 KB |
testcase_76 | AC | 86 ms
24,812 KB |
testcase_77 | AC | 93 ms
25,196 KB |
testcase_78 | AC | 96 ms
24,812 KB |
testcase_79 | AC | 104 ms
24,556 KB |
testcase_80 | AC | 108 ms
25,196 KB |
testcase_81 | AC | 89 ms
24,812 KB |
testcase_82 | AC | 112 ms
24,812 KB |
testcase_83 | AC | 116 ms
24,800 KB |
testcase_84 | AC | 123 ms
24,940 KB |
testcase_85 | AC | 128 ms
24,812 KB |
testcase_86 | AC | 109 ms
24,556 KB |
testcase_87 | AC | 113 ms
24,812 KB |
testcase_88 | AC | 139 ms
24,940 KB |
testcase_89 | AC | 115 ms
25,196 KB |
testcase_90 | AC | 101 ms
24,940 KB |
testcase_91 | AC | 113 ms
24,812 KB |
testcase_92 | AC | 102 ms
24,812 KB |
testcase_93 | AC | 122 ms
24,812 KB |
testcase_94 | AC | 102 ms
24,812 KB |
testcase_95 | AC | 108 ms
24,812 KB |
testcase_96 | AC | 100 ms
25,196 KB |
testcase_97 | AC | 100 ms
24,556 KB |
testcase_98 | AC | 96 ms
24,556 KB |
testcase_99 | AC | 112 ms
25,180 KB |
testcase_100 | AC | 115 ms
25,196 KB |
testcase_101 | AC | 124 ms
24,812 KB |
testcase_102 | AC | 102 ms
24,940 KB |
testcase_103 | AC | 109 ms
24,812 KB |
testcase_104 | AC | 110 ms
24,812 KB |
testcase_105 | AC | 109 ms
24,812 KB |
testcase_106 | AC | 98 ms
24,940 KB |
testcase_107 | AC | 111 ms
24,940 KB |
testcase_108 | AC | 103 ms
25,196 KB |
testcase_109 | AC | 124 ms
24,812 KB |
testcase_110 | AC | 101 ms
25,196 KB |
testcase_111 | AC | 105 ms
24,556 KB |
testcase_112 | AC | 95 ms
24,812 KB |
testcase_113 | AC | 131 ms
25,052 KB |
testcase_114 | AC | 132 ms
24,812 KB |
testcase_115 | AC | 112 ms
24,812 KB |
testcase_116 | AC | 134 ms
24,812 KB |
testcase_117 | AC | 115 ms
24,800 KB |
testcase_118 | AC | 122 ms
25,196 KB |
testcase_119 | AC | 107 ms
24,556 KB |
testcase_120 | AC | 97 ms
24,556 KB |
testcase_121 | AC | 118 ms
25,196 KB |
testcase_122 | AC | 114 ms
24,556 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int m = n * (n - 1); vector<int> dx(m), dy(m); for (int i = 1; i < m; i++) { cout << "? " << i + 1 << " " << 1 << endl; cin >> dx.at(i) >> dy.at(i); } int dxmax = *max_element(dx.begin(), dx.end()), dymax = *max_element(dy.begin(), dy.end()), dxmin = *min_element(dx.begin(), dx.end()), dymin = *min_element(dy.begin(), dy.end()); if (dxmax - dxmin < n - 1) { swap(dxmax, dymax); swap(dxmin, dymin); for (int i = 0; i < m; i++) { swap(dx.at(i), dy.at(i)); } } assert(dxmax - dxmin == n - 1); assert(dymax - dymin == n - 2); map<pair<int, int>, bool> twoway; vector index(n, vector(n - 1, -1)); for (int i = 0; i < m; i++) { if (index.at(dx.at(i) - dxmin).at(dy.at(i) - dymin) != -1) { twoway[{dx.at(i), dy.at(i)}] = true; swap(dx.at(i), dy.at(i)); twoway[{dx.at(i), dy.at(i)}] = true; } index.at(dx.at(i) - dxmin).at(dy.at(i) - dymin) = i; } int base = -1; for (int i = 0; i < m; i++) { if (dxmin != dymin and dx.at(i) == dxmin and dy.at(i) == dymin) { base = i; break; } if (dxmin == dymin and dx.at(i) == dxmax and dy.at(i) == dymax) { base = i; break; } } vector<bool> visited(m); for (int i = 0; i < m; i++) { if (visited.at(i)) continue; if (not twoway[{dx.at(i), dy.at(i)}]) continue; assert(i == index.at(dx.at(i) - dxmin).at(dy.at(i) - dymin)); int co_i = index.at(dy.at(i) - dxmin).at(dx.at(i) - dymin); cout << "? " << i + 1 << " " << base + 1 << endl; int dxbase, dybase; cin >> dxbase >> dybase; if (dx.at(i) != dxbase + dx.at(base)) { swap(dx.at(i), dy.at(i)); } if (dx.at(i) != dxbase + dx.at(base)) { swap(dxbase, dybase); } if (dx.at(i) != dxbase + dx.at(base)) { swap(dx.at(i), dy.at(i)); } assert(dx.at(i) == dxbase + dx.at(base)); assert(dy.at(i) == dybase + dy.at(base)); dx.at(co_i) = dy.at(i); dy.at(co_i) = dx.at(i); visited.at(co_i) = true; } cout << "!"; for (int i = 0; i < m; i++) { cout << " " << n * (dy.at(i) - dymin) + (dx.at(i) - dxmin) + n; } cout << endl; }