結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | tkmst201 |
提出日時 | 2020-12-04 12:20:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,610 bytes |
コンパイル時間 | 2,415 ms |
コンパイル使用メモリ | 217,032 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 09:25:27 |
合計ジャッジ時間 | 17,385 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 25 ms
25,452 KB |
testcase_02 | WA | - |
testcase_03 | AC | 23 ms
25,220 KB |
testcase_04 | AC | 27 ms
24,836 KB |
testcase_05 | AC | 23 ms
24,964 KB |
testcase_06 | AC | 23 ms
24,836 KB |
testcase_07 | AC | 23 ms
25,220 KB |
testcase_08 | AC | 25 ms
25,220 KB |
testcase_09 | AC | 24 ms
25,220 KB |
testcase_10 | AC | 24 ms
24,580 KB |
testcase_11 | AC | 24 ms
24,836 KB |
testcase_12 | AC | 25 ms
25,112 KB |
testcase_13 | AC | 25 ms
24,812 KB |
testcase_14 | AC | 24 ms
25,452 KB |
testcase_15 | AC | 25 ms
24,556 KB |
testcase_16 | WA | - |
testcase_17 | AC | 23 ms
24,812 KB |
testcase_18 | AC | 25 ms
25,324 KB |
testcase_19 | AC | 25 ms
25,196 KB |
testcase_20 | AC | 23 ms
24,812 KB |
testcase_21 | AC | 25 ms
25,196 KB |
testcase_22 | AC | 24 ms
24,812 KB |
testcase_23 | AC | 25 ms
24,784 KB |
testcase_24 | WA | - |
testcase_25 | AC | 25 ms
24,812 KB |
testcase_26 | AC | 25 ms
25,196 KB |
testcase_27 | AC | 25 ms
25,196 KB |
testcase_28 | AC | 25 ms
25,196 KB |
testcase_29 | AC | 25 ms
25,196 KB |
testcase_30 | AC | 25 ms
25,040 KB |
testcase_31 | AC | 24 ms
25,196 KB |
testcase_32 | AC | 25 ms
25,196 KB |
testcase_33 | AC | 25 ms
24,940 KB |
testcase_34 | AC | 25 ms
24,812 KB |
testcase_35 | AC | 25 ms
24,812 KB |
testcase_36 | AC | 25 ms
25,196 KB |
testcase_37 | AC | 26 ms
25,196 KB |
testcase_38 | AC | 26 ms
24,940 KB |
testcase_39 | AC | 25 ms
24,812 KB |
testcase_40 | AC | 25 ms
25,196 KB |
testcase_41 | AC | 25 ms
25,196 KB |
testcase_42 | AC | 26 ms
24,556 KB |
testcase_43 | AC | 26 ms
25,436 KB |
testcase_44 | WA | - |
testcase_45 | AC | 27 ms
24,812 KB |
testcase_46 | AC | 27 ms
24,568 KB |
testcase_47 | AC | 27 ms
24,812 KB |
testcase_48 | AC | 30 ms
24,812 KB |
testcase_49 | AC | 30 ms
25,196 KB |
testcase_50 | AC | 30 ms
24,812 KB |
testcase_51 | AC | 32 ms
24,812 KB |
testcase_52 | AC | 35 ms
24,812 KB |
testcase_53 | AC | 38 ms
25,196 KB |
testcase_54 | AC | 35 ms
24,940 KB |
testcase_55 | AC | 37 ms
25,196 KB |
testcase_56 | AC | 40 ms
24,940 KB |
testcase_57 | AC | 40 ms
24,556 KB |
testcase_58 | AC | 42 ms
24,812 KB |
testcase_59 | AC | 41 ms
25,196 KB |
testcase_60 | AC | 49 ms
25,196 KB |
testcase_61 | AC | 53 ms
24,428 KB |
testcase_62 | AC | 52 ms
24,812 KB |
testcase_63 | AC | 55 ms
24,856 KB |
testcase_64 | AC | 54 ms
24,556 KB |
testcase_65 | AC | 57 ms
25,196 KB |
testcase_66 | AC | 65 ms
25,196 KB |
testcase_67 | AC | 62 ms
25,068 KB |
testcase_68 | AC | 63 ms
24,812 KB |
testcase_69 | AC | 67 ms
25,196 KB |
testcase_70 | AC | 66 ms
24,812 KB |
testcase_71 | AC | 71 ms
24,812 KB |
testcase_72 | AC | 70 ms
24,812 KB |
testcase_73 | AC | 70 ms
25,052 KB |
testcase_74 | AC | 82 ms
25,196 KB |
testcase_75 | AC | 77 ms
24,812 KB |
testcase_76 | AC | 86 ms
24,812 KB |
testcase_77 | AC | 93 ms
25,196 KB |
testcase_78 | AC | 98 ms
25,196 KB |
testcase_79 | AC | 108 ms
24,940 KB |
testcase_80 | AC | 110 ms
25,196 KB |
testcase_81 | AC | 92 ms
24,812 KB |
testcase_82 | AC | 116 ms
24,940 KB |
testcase_83 | AC | 116 ms
25,196 KB |
testcase_84 | AC | 126 ms
25,196 KB |
testcase_85 | AC | 131 ms
24,812 KB |
testcase_86 | AC | 109 ms
24,800 KB |
testcase_87 | AC | 114 ms
24,812 KB |
testcase_88 | AC | 139 ms
25,196 KB |
testcase_89 | AC | 116 ms
24,556 KB |
testcase_90 | AC | 101 ms
24,812 KB |
testcase_91 | AC | 114 ms
24,812 KB |
testcase_92 | AC | 103 ms
24,812 KB |
testcase_93 | AC | 122 ms
24,556 KB |
testcase_94 | AC | 103 ms
25,196 KB |
testcase_95 | AC | 109 ms
24,556 KB |
testcase_96 | AC | 100 ms
25,424 KB |
testcase_97 | AC | 99 ms
24,812 KB |
testcase_98 | AC | 97 ms
24,812 KB |
testcase_99 | AC | 114 ms
25,580 KB |
testcase_100 | AC | 114 ms
25,196 KB |
testcase_101 | AC | 122 ms
24,556 KB |
testcase_102 | AC | 101 ms
24,812 KB |
testcase_103 | AC | 110 ms
24,940 KB |
testcase_104 | AC | 109 ms
24,556 KB |
testcase_105 | AC | 111 ms
24,940 KB |
testcase_106 | AC | 100 ms
25,452 KB |
testcase_107 | AC | 112 ms
25,196 KB |
testcase_108 | AC | 104 ms
24,556 KB |
testcase_109 | AC | 126 ms
24,556 KB |
testcase_110 | AC | 102 ms
24,940 KB |
testcase_111 | AC | 104 ms
25,068 KB |
testcase_112 | AC | 98 ms
24,812 KB |
testcase_113 | AC | 131 ms
24,556 KB |
testcase_114 | AC | 134 ms
24,800 KB |
testcase_115 | AC | 112 ms
24,716 KB |
testcase_116 | AC | 135 ms
25,196 KB |
testcase_117 | AC | 115 ms
24,812 KB |
testcase_118 | AC | 123 ms
24,556 KB |
testcase_119 | AC | 109 ms
25,196 KB |
testcase_120 | AC | 101 ms
24,556 KB |
testcase_121 | AC | 122 ms
24,812 KB |
testcase_122 | AC | 119 ms
24,556 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(0, 1); 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 = tidx == 0 ? res[vec[0]] : 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; }