結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | tkmst201 |
提出日時 | 2020-12-04 12:18:15 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,584 bytes |
コンパイル時間 | 2,528 ms |
コンパイル使用メモリ | 216,448 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 09:25:46 |
合計ジャッジ時間 | 17,161 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 25 ms
24,812 KB |
testcase_02 | WA | - |
testcase_03 | AC | 25 ms
24,580 KB |
testcase_04 | AC | 24 ms
25,220 KB |
testcase_05 | AC | 25 ms
24,580 KB |
testcase_06 | AC | 25 ms
24,964 KB |
testcase_07 | AC | 24 ms
24,836 KB |
testcase_08 | AC | 25 ms
25,220 KB |
testcase_09 | AC | 25 ms
25,220 KB |
testcase_10 | AC | 24 ms
24,452 KB |
testcase_11 | AC | 25 ms
25,220 KB |
testcase_12 | AC | 24 ms
24,580 KB |
testcase_13 | AC | 26 ms
24,812 KB |
testcase_14 | AC | 25 ms
24,812 KB |
testcase_15 | AC | 24 ms
25,196 KB |
testcase_16 | WA | - |
testcase_17 | AC | 25 ms
25,184 KB |
testcase_18 | AC | 25 ms
24,812 KB |
testcase_19 | AC | 25 ms
24,812 KB |
testcase_20 | AC | 26 ms
25,068 KB |
testcase_21 | AC | 25 ms
25,052 KB |
testcase_22 | AC | 24 ms
24,812 KB |
testcase_23 | AC | 25 ms
25,196 KB |
testcase_24 | WA | - |
testcase_25 | AC | 24 ms
25,196 KB |
testcase_26 | AC | 25 ms
25,196 KB |
testcase_27 | AC | 26 ms
24,812 KB |
testcase_28 | AC | 25 ms
24,812 KB |
testcase_29 | AC | 24 ms
24,812 KB |
testcase_30 | AC | 25 ms
24,556 KB |
testcase_31 | AC | 25 ms
24,556 KB |
testcase_32 | AC | 25 ms
24,556 KB |
testcase_33 | AC | 25 ms
24,544 KB |
testcase_34 | AC | 25 ms
24,812 KB |
testcase_35 | AC | 25 ms
25,040 KB |
testcase_36 | AC | 25 ms
25,196 KB |
testcase_37 | AC | 25 ms
25,196 KB |
testcase_38 | AC | 25 ms
24,940 KB |
testcase_39 | AC | 25 ms
25,196 KB |
testcase_40 | AC | 26 ms
25,196 KB |
testcase_41 | AC | 25 ms
25,196 KB |
testcase_42 | AC | 26 ms
24,812 KB |
testcase_43 | AC | 26 ms
24,812 KB |
testcase_44 | WA | - |
testcase_45 | AC | 28 ms
25,196 KB |
testcase_46 | AC | 28 ms
25,196 KB |
testcase_47 | AC | 28 ms
24,812 KB |
testcase_48 | AC | 30 ms
25,196 KB |
testcase_49 | AC | 31 ms
24,812 KB |
testcase_50 | AC | 31 ms
24,812 KB |
testcase_51 | AC | 33 ms
25,196 KB |
testcase_52 | AC | 35 ms
25,196 KB |
testcase_53 | AC | 37 ms
24,812 KB |
testcase_54 | AC | 35 ms
24,556 KB |
testcase_55 | AC | 38 ms
25,040 KB |
testcase_56 | AC | 40 ms
24,812 KB |
testcase_57 | AC | 41 ms
24,812 KB |
testcase_58 | AC | 43 ms
24,556 KB |
testcase_59 | AC | 42 ms
24,940 KB |
testcase_60 | AC | 49 ms
24,940 KB |
testcase_61 | AC | 53 ms
25,196 KB |
testcase_62 | AC | 53 ms
24,812 KB |
testcase_63 | AC | 56 ms
24,940 KB |
testcase_64 | AC | 54 ms
24,556 KB |
testcase_65 | AC | 57 ms
24,556 KB |
testcase_66 | AC | 62 ms
25,192 KB |
testcase_67 | AC | 64 ms
24,812 KB |
testcase_68 | AC | 62 ms
24,556 KB |
testcase_69 | AC | 67 ms
24,812 KB |
testcase_70 | AC | 68 ms
24,812 KB |
testcase_71 | AC | 72 ms
24,812 KB |
testcase_72 | AC | 71 ms
25,068 KB |
testcase_73 | AC | 70 ms
24,812 KB |
testcase_74 | AC | 82 ms
24,812 KB |
testcase_75 | AC | 78 ms
25,196 KB |
testcase_76 | AC | 86 ms
25,196 KB |
testcase_77 | AC | 94 ms
24,812 KB |
testcase_78 | AC | 100 ms
24,812 KB |
testcase_79 | AC | 108 ms
24,812 KB |
testcase_80 | AC | 111 ms
24,428 KB |
testcase_81 | AC | 92 ms
24,812 KB |
testcase_82 | AC | 117 ms
25,196 KB |
testcase_83 | AC | 116 ms
24,812 KB |
testcase_84 | AC | 124 ms
24,812 KB |
testcase_85 | AC | 132 ms
25,196 KB |
testcase_86 | AC | 110 ms
24,812 KB |
testcase_87 | AC | 116 ms
25,184 KB |
testcase_88 | AC | 140 ms
24,800 KB |
testcase_89 | AC | 116 ms
25,196 KB |
testcase_90 | AC | 103 ms
24,928 KB |
testcase_91 | AC | 115 ms
24,556 KB |
testcase_92 | AC | 105 ms
25,040 KB |
testcase_93 | AC | 122 ms
24,812 KB |
testcase_94 | AC | 105 ms
25,068 KB |
testcase_95 | AC | 114 ms
25,196 KB |
testcase_96 | AC | 104 ms
24,940 KB |
testcase_97 | AC | 103 ms
24,812 KB |
testcase_98 | AC | 97 ms
24,812 KB |
testcase_99 | AC | 114 ms
25,196 KB |
testcase_100 | AC | 115 ms
25,196 KB |
testcase_101 | AC | 127 ms
25,196 KB |
testcase_102 | AC | 104 ms
24,812 KB |
testcase_103 | AC | 111 ms
24,812 KB |
testcase_104 | AC | 110 ms
24,556 KB |
testcase_105 | AC | 113 ms
25,196 KB |
testcase_106 | AC | 99 ms
24,812 KB |
testcase_107 | AC | 113 ms
24,812 KB |
testcase_108 | AC | 106 ms
25,068 KB |
testcase_109 | AC | 129 ms
24,812 KB |
testcase_110 | AC | 104 ms
24,812 KB |
testcase_111 | AC | 106 ms
25,040 KB |
testcase_112 | AC | 97 ms
24,568 KB |
testcase_113 | AC | 132 ms
25,064 KB |
testcase_114 | AC | 134 ms
24,812 KB |
testcase_115 | AC | 112 ms
24,812 KB |
testcase_116 | AC | 138 ms
24,812 KB |
testcase_117 | AC | 117 ms
25,196 KB |
testcase_118 | AC | 124 ms
25,196 KB |
testcase_119 | AC | 107 ms
25,196 KB |
testcase_120 | AC | 100 ms
24,556 KB |
testcase_121 | AC | 120 ms
24,428 KB |
testcase_122 | AC | 117 ms
25,196 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair<int, int>; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N; cin >> N; auto query = [](int i, int j) -> pii { ++i; ++j; cout << "? " << i << " " << j << endl; int p, q; cin >> p >> q; return {p, q}; }; if (N == 2) { auto res = query(1, 2); if (res.second == 1) puts("! 1 2"); else puts("! 2 1"); return 0; } vector<pii> res(N * N - N); FOR(i, 1, res.size()) res[i] = query(0, i); const int bias = N; vector<int> cnt(2 * N); FOR(i, 1, res.size()) { ++cnt[res[i].first + bias]; ++cnt[res[i].second + bias]; } int mx = -INF, mn = INF; REP(i, cnt.size()) { if (!cnt[i]) continue; chmax(mx, i - bias); chmin(mn, i - bias); } vector<pii> ans(res.size(), {-INF, -INF}); if (cnt[mn + bias] == N || cnt[mn + bias] == 2 * N - 1 || cnt[mn + bias] == 2 * N - 2) ans[0] = {N - 1 + mn, mx};// A_1 <= B_1 else ans[0] = {1 + mx, N - 1 + mn}; // A_1 > B_1 map<pii, vector<int>> mm; // (p, q) = {idx...} FOR(i, 1, res.size()) mm[res[i]].emplace_back(i); int tidx = 0; for (const auto & [p, vec] : mm) { if (vec.size() != 1) continue; int t1 = ans[0].first - p.first, t2 = ans[0].second - p.second; if (!(1 <= t1 && t1 < N && 0 <= t2 && t2 < N)) { t1 = ans[0].first - p.second; t2 = ans[0].second - p.first; } ans[vec[0]] = {t1, t2}; if (ans[0].first <= ans[0].second && ans[vec[0]] == pii{N - 1, 0}) tidx = vec[0]; if (ans[0].first > ans[0].second && ans[vec[0]] == pii{1, N - 1}) tidx = vec[0]; } for (const auto & [p, vec] : mm) { if (vec.size() == 1) continue; auto q = query(tidx, vec[0]); pii pred1 {ans[0].first - p.first, ans[0].second - p.second}; pii pred2 {ans[0].first - p.second, ans[0].second - p.first}; if (ans[0].first <= ans[0].second) ans[vec[0]] = {N - 1 - q.second, 0 - q.first}; else ans[vec[0]] = {1 - q.first, N - 1 - q.second}; ans[vec[1]] = ans[vec[0]] == pred1 ? pred2 : pred1; } cout << "! "; REP(i, ans.size()) cout << ans[i].first * N + ans[i].second << " \n"[i + 1 == ans.size()]; cout << flush; }