結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | やむなく |
提出日時 | 2020-12-03 02:02:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,205 bytes |
コンパイル時間 | 2,827 ms |
コンパイル使用メモリ | 222,044 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 08:12:46 |
合計ジャッジ時間 | 43,784 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
24,556 KB |
testcase_01 | WA | - |
testcase_02 | AC | 24 ms
24,836 KB |
testcase_03 | AC | 24 ms
25,220 KB |
testcase_04 | AC | 27 ms
25,476 KB |
testcase_05 | AC | 23 ms
24,836 KB |
testcase_06 | AC | 24 ms
25,220 KB |
testcase_07 | AC | 24 ms
24,836 KB |
testcase_08 | AC | 24 ms
25,220 KB |
testcase_09 | AC | 24 ms
25,220 KB |
testcase_10 | AC | 24 ms
24,836 KB |
testcase_11 | AC | 25 ms
25,092 KB |
testcase_12 | AC | 23 ms
25,220 KB |
testcase_13 | AC | 25 ms
24,940 KB |
testcase_14 | AC | 25 ms
24,812 KB |
testcase_15 | AC | 24 ms
25,196 KB |
testcase_16 | AC | 24 ms
24,812 KB |
testcase_17 | AC | 25 ms
25,196 KB |
testcase_18 | AC | 24 ms
25,580 KB |
testcase_19 | AC | 24 ms
24,556 KB |
testcase_20 | AC | 24 ms
25,196 KB |
testcase_21 | AC | 23 ms
25,196 KB |
testcase_22 | AC | 24 ms
25,196 KB |
testcase_23 | AC | 24 ms
24,556 KB |
testcase_24 | AC | 24 ms
24,812 KB |
testcase_25 | AC | 24 ms
24,812 KB |
testcase_26 | AC | 25 ms
24,940 KB |
testcase_27 | AC | 25 ms
25,196 KB |
testcase_28 | AC | 25 ms
25,196 KB |
testcase_29 | AC | 25 ms
24,812 KB |
testcase_30 | AC | 24 ms
24,800 KB |
testcase_31 | AC | 25 ms
24,812 KB |
testcase_32 | WA | - |
testcase_33 | AC | 25 ms
25,184 KB |
testcase_34 | AC | 26 ms
24,812 KB |
testcase_35 | AC | 25 ms
25,196 KB |
testcase_36 | AC | 25 ms
25,452 KB |
testcase_37 | AC | 25 ms
24,824 KB |
testcase_38 | WA | - |
testcase_39 | AC | 25 ms
24,812 KB |
testcase_40 | AC | 26 ms
24,812 KB |
testcase_41 | AC | 26 ms
24,928 KB |
testcase_42 | AC | 25 ms
24,556 KB |
testcase_43 | AC | 26 ms
24,940 KB |
testcase_44 | AC | 26 ms
25,196 KB |
testcase_45 | AC | 27 ms
24,812 KB |
testcase_46 | AC | 28 ms
24,812 KB |
testcase_47 | AC | 29 ms
25,196 KB |
testcase_48 | AC | 29 ms
24,812 KB |
testcase_49 | AC | 31 ms
25,196 KB |
testcase_50 | AC | 34 ms
24,556 KB |
testcase_51 | AC | 35 ms
24,940 KB |
testcase_52 | AC | 38 ms
24,940 KB |
testcase_53 | AC | 43 ms
24,940 KB |
testcase_54 | AC | 43 ms
25,196 KB |
testcase_55 | AC | 47 ms
25,580 KB |
testcase_56 | AC | 52 ms
25,196 KB |
testcase_57 | AC | 55 ms
25,196 KB |
testcase_58 | AC | 61 ms
24,812 KB |
testcase_59 | AC | 64 ms
24,556 KB |
testcase_60 | AC | 76 ms
25,324 KB |
testcase_61 | AC | 86 ms
25,196 KB |
testcase_62 | AC | 92 ms
25,452 KB |
testcase_63 | AC | 102 ms
24,812 KB |
testcase_64 | AC | 107 ms
25,196 KB |
testcase_65 | AC | 119 ms
24,812 KB |
testcase_66 | AC | 135 ms
25,196 KB |
testcase_67 | AC | 148 ms
24,812 KB |
testcase_68 | AC | 156 ms
24,940 KB |
testcase_69 | AC | 176 ms
25,196 KB |
testcase_70 | AC | 192 ms
25,068 KB |
testcase_71 | AC | 211 ms
24,940 KB |
testcase_72 | AC | 234 ms
24,556 KB |
testcase_73 | AC | 249 ms
25,452 KB |
testcase_74 | AC | 279 ms
24,812 KB |
testcase_75 | AC | 300 ms
24,556 KB |
testcase_76 | AC | 334 ms
25,196 KB |
testcase_77 | AC | 374 ms
24,812 KB |
testcase_78 | AC | 402 ms
25,196 KB |
testcase_79 | AC | 451 ms
25,068 KB |
testcase_80 | AC | 478 ms
24,940 KB |
testcase_81 | AC | 498 ms
25,196 KB |
testcase_82 | AC | 574 ms
25,196 KB |
testcase_83 | AC | 668 ms
24,812 KB |
testcase_84 | AC | 670 ms
25,452 KB |
testcase_85 | AC | 774 ms
25,196 KB |
testcase_86 | AC | 655 ms
24,812 KB |
testcase_87 | AC | 703 ms
24,856 KB |
testcase_88 | AC | 796 ms
25,196 KB |
testcase_89 | AC | 661 ms
24,812 KB |
testcase_90 | AC | 758 ms
24,940 KB |
testcase_91 | AC | 607 ms
25,196 KB |
testcase_92 | AC | 709 ms
24,940 KB |
testcase_93 | AC | 667 ms
24,928 KB |
testcase_94 | AC | 594 ms
25,196 KB |
testcase_95 | AC | 640 ms
25,196 KB |
testcase_96 | AC | 591 ms
24,940 KB |
testcase_97 | AC | 703 ms
24,812 KB |
testcase_98 | AC | 601 ms
24,812 KB |
testcase_99 | AC | 602 ms
25,196 KB |
testcase_100 | AC | 617 ms
24,812 KB |
testcase_101 | AC | 656 ms
24,556 KB |
testcase_102 | AC | 591 ms
25,196 KB |
testcase_103 | AC | 609 ms
24,556 KB |
testcase_104 | AC | 644 ms
25,196 KB |
testcase_105 | AC | 758 ms
24,812 KB |
testcase_106 | AC | 630 ms
24,556 KB |
testcase_107 | AC | 769 ms
25,196 KB |
testcase_108 | AC | 744 ms
25,196 KB |
testcase_109 | AC | 783 ms
25,196 KB |
testcase_110 | AC | 638 ms
25,196 KB |
testcase_111 | AC | 764 ms
24,544 KB |
testcase_112 | AC | 597 ms
24,556 KB |
testcase_113 | AC | 783 ms
24,556 KB |
testcase_114 | AC | 729 ms
25,196 KB |
testcase_115 | AC | 696 ms
25,196 KB |
testcase_116 | AC | 798 ms
24,812 KB |
testcase_117 | AC | 716 ms
25,196 KB |
testcase_118 | AC | 762 ms
25,452 KB |
testcase_119 | AC | 745 ms
25,196 KB |
testcase_120 | AC | 645 ms
24,940 KB |
testcase_121 | AC | 658 ms
24,940 KB |
testcase_122 | AC | 645 ms
24,556 KB |
ソースコード
// // Created by yamunaku on 2020/12/03. // #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; #define rep(i, n) for(int i = 0; i < (n); i++) #define repl(i, l, r) for(int i = (l); i < (r); i++) #define per(i, n) for(int i = ((n)-1); i >= 0; i--) #define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--) #define all(x) (x).begin(),(x).end() #define MOD9 998244353 #define MOD1 1000000007 #define IINF 1000000000 #define LINF 1000000000000000000 #define SP <<" "<< #define CYES cout<<"Yes"<<endl #define CNO cout<<"No"<<endl #define CFS cin.tie(0);ios::sync_with_stdio(false) #define CST(x) cout<<fixed<<setprecision(x) using ll = long long; using ld = long double; using vi = vector<int>; using mti = vector<vector<int>>; using vl = vector<ll>; using mtl = vector<vector<ll>>; using pi = pair<int, int>; using pl = pair<ll, ll>; template<typename T> using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>; pair<int, int> query(int i, int j) { cout << "?" SP i + 1 SP j + 1 << endl; int p, q; cin >> p >> q; return {p, q}; } int main() { //CFS; int n; cin >> n; map<pair<int, int>, vector<int>> mp; repl(i, 1, n * n - n) { auto p = query(i, 0); mp[p].push_back(i); } int pi = -1, pj = -1; rep(i, n - 1) { rep(j, n) { map<pair<int, int>, int> sz; rep(k, n - 1) { rep(l, n) { if (i != k || j != l) { int p = k - i, q = l - j; if (p > q) swap(p, q); sz[{p, q}]++; } } } auto itr = sz.begin(); auto itr2 = mp.begin(); for (; itr != sz.end(); itr++, itr2++) { if (itr2->first != itr->first || itr2->second.size() != itr->second) goto next; } pi = i, pj = j; next:; } } mti ans(n - 1, vi(n, -1)); ans[pi][pj] = 0; // cout << pi SP pj << endl; auto pl = mp.begin()->first; if (pl.first != pl.second) { int l = mp.begin()->second[0]; for (auto &c : mp) { int nx = pi + c.first.first, ny = pj + c.first.second; if (c.second.size() == 1) { if (nx < 0 || n - 1 <= nx || ny < 0 || n <= ny) { nx = pi + c.first.second, ny = pj + c.first.first; } ans[nx][ny] = c.second[0]; } else { auto s = query(c.second[0], l); if (nx == s.first && ny == s.second || nx == s.second && ny == s.first) { ans[nx][ny] = c.second[0]; ans[pi + c.first.second][pj + c.first.first] = c.second[1]; } else { ans[nx][ny] = c.second[1]; ans[pi + c.first.second][pj + c.first.first] = c.second[0]; } } } } else { int r = mp.rbegin()->second[0]; for (auto &c : mp) { int nx = pi + c.first.first, ny = pj + c.first.second; if (c.second.size() == 1) { if (nx < 0 || n - 1 <= nx || ny < 0 || n <= ny) { nx = pi + c.first.second, ny = pj + c.first.first; } ans[nx][ny] = c.second[0]; } else { auto s = query(c.second[0], r); if (nx == s.first + n - 2 && ny == s.second + n - 1 || nx == s.second + n - 2 && ny == s.first + n - 1) { ans[nx][ny] = c.second[0]; ans[pi + c.first.second][pj + c.first.first] = c.second[1]; } else { ans[nx][ny] = c.second[1]; ans[pi + c.first.second][pj + c.first.first] = c.second[0]; } } } } // rep(i, n - 1) { // rep(j, n) { // cout << ans[i][j] << " "; // } // cout << endl; // } vi ansp(n * n - n); rep(i, n - 1) rep(j, n) ansp[ans[i][j]] = i * n + j + n; cout << "!"; for (auto &x : ansp) cout << " " << x; cout << endl; return 0; }