結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | tkmst201 |
提出日時 | 2020-12-03 19:16:46 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,702 bytes |
コンパイル時間 | 2,360 ms |
コンパイル使用メモリ | 216,460 KB |
実行使用メモリ | 25,836 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 08:51:45 |
合計ジャッジ時間 | 25,650 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 24 ms
24,940 KB |
testcase_02 | WA | - |
testcase_03 | AC | 25 ms
25,220 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 24 ms
25,208 KB |
testcase_10 | AC | 25 ms
24,836 KB |
testcase_11 | AC | 25 ms
25,220 KB |
testcase_12 | WA | - |
testcase_13 | AC | 25 ms
24,556 KB |
testcase_14 | AC | 24 ms
25,196 KB |
testcase_15 | AC | 26 ms
24,556 KB |
testcase_16 | WA | - |
testcase_17 | AC | 25 ms
24,556 KB |
testcase_18 | WA | - |
testcase_19 | AC | 24 ms
25,196 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 26 ms
25,196 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 24 ms
24,544 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 25 ms
24,556 KB |
testcase_29 | AC | 25 ms
24,812 KB |
testcase_30 | WA | - |
testcase_31 | AC | 25 ms
25,052 KB |
testcase_32 | AC | 25 ms
25,196 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 24 ms
24,940 KB |
testcase_36 | WA | - |
testcase_37 | AC | 25 ms
24,812 KB |
testcase_38 | AC | 26 ms
25,452 KB |
testcase_39 | AC | 25 ms
24,940 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 25 ms
24,556 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | AC | 27 ms
24,812 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 33 ms
24,812 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | AC | 34 ms
24,940 KB |
testcase_55 | WA | - |
testcase_56 | AC | 39 ms
25,196 KB |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | AC | 41 ms
25,196 KB |
testcase_60 | WA | - |
testcase_61 | AC | 53 ms
24,940 KB |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 62 ms
24,940 KB |
testcase_69 | AC | 67 ms
24,940 KB |
testcase_70 | AC | 68 ms
25,196 KB |
testcase_71 | WA | - |
testcase_72 | AC | 71 ms
24,544 KB |
testcase_73 | AC | 69 ms
24,940 KB |
testcase_74 | WA | - |
testcase_75 | AC | 77 ms
24,812 KB |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | AC | 110 ms
24,812 KB |
testcase_81 | AC | 92 ms
25,196 KB |
testcase_82 | AC | 118 ms
25,424 KB |
testcase_83 | AC | 121 ms
25,196 KB |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | AC | 110 ms
25,136 KB |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | AC | 118 ms
24,940 KB |
testcase_90 | AC | 104 ms
25,484 KB |
testcase_91 | AC | 117 ms
24,940 KB |
testcase_92 | AC | 105 ms
24,556 KB |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | AC | 112 ms
24,812 KB |
testcase_96 | AC | 102 ms
25,196 KB |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | AC | 114 ms
24,556 KB |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | AC | 103 ms
25,196 KB |
testcase_103 | AC | 112 ms
25,196 KB |
testcase_104 | WA | - |
testcase_105 | AC | 110 ms
24,556 KB |
testcase_106 | AC | 99 ms
25,196 KB |
testcase_107 | AC | 113 ms
24,940 KB |
testcase_108 | AC | 105 ms
24,812 KB |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | AC | 136 ms
25,196 KB |
testcase_117 | AC | 118 ms
24,928 KB |
testcase_118 | AC | 122 ms
25,196 KB |
testcase_119 | AC | 106 ms
25,076 KB |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | WA | - |
ソースコード
#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 { 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, N * N - N) res[i] = query(1, i + 1); 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[mx + bias] == (N - 1) - 1 || cnt[mn + bias] == (N - 1) - 1) { // A_1 <= B_1 ans[0] = {mn + (N - 1), mx}; } else { // A_1 > B_1 ans[0] = {mx + 1, mn + (N - 1)}; } map<pii, vector<int>> mm; // (p, q) = {idx...} FOR(i, 1, res.size()) { if (res[i].first == res[i].second) ans[i] = {ans[0].first - res[i].first, ans[0].second - res[i].second}; else 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 + 1, vec[0] + 1); 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; }