結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | やむなく |
提出日時 | 2020-12-03 02:11:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 802 ms / 2,000 ms |
コード長 | 4,197 bytes |
コンパイル時間 | 2,482 ms |
コンパイル使用メモリ | 221,760 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 08:15:07 |
合計ジャッジ時間 | 43,662 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
25,068 KB |
testcase_01 | AC | 22 ms
24,812 KB |
testcase_02 | AC | 22 ms
24,836 KB |
testcase_03 | AC | 23 ms
24,836 KB |
testcase_04 | AC | 22 ms
25,208 KB |
testcase_05 | AC | 22 ms
24,964 KB |
testcase_06 | AC | 23 ms
24,964 KB |
testcase_07 | AC | 23 ms
24,580 KB |
testcase_08 | AC | 22 ms
24,580 KB |
testcase_09 | AC | 22 ms
24,836 KB |
testcase_10 | AC | 23 ms
24,580 KB |
testcase_11 | AC | 22 ms
24,836 KB |
testcase_12 | AC | 23 ms
24,836 KB |
testcase_13 | AC | 23 ms
24,556 KB |
testcase_14 | AC | 23 ms
24,812 KB |
testcase_15 | AC | 22 ms
25,196 KB |
testcase_16 | AC | 22 ms
24,812 KB |
testcase_17 | AC | 22 ms
24,556 KB |
testcase_18 | AC | 23 ms
24,812 KB |
testcase_19 | AC | 23 ms
24,812 KB |
testcase_20 | AC | 23 ms
24,940 KB |
testcase_21 | AC | 23 ms
25,452 KB |
testcase_22 | AC | 24 ms
24,812 KB |
testcase_23 | AC | 24 ms
24,556 KB |
testcase_24 | AC | 23 ms
24,556 KB |
testcase_25 | AC | 23 ms
25,184 KB |
testcase_26 | AC | 23 ms
24,940 KB |
testcase_27 | AC | 24 ms
24,940 KB |
testcase_28 | AC | 22 ms
25,068 KB |
testcase_29 | AC | 23 ms
25,196 KB |
testcase_30 | AC | 23 ms
25,196 KB |
testcase_31 | AC | 23 ms
25,196 KB |
testcase_32 | AC | 24 ms
24,812 KB |
testcase_33 | AC | 23 ms
24,556 KB |
testcase_34 | AC | 23 ms
25,184 KB |
testcase_35 | AC | 24 ms
24,556 KB |
testcase_36 | AC | 24 ms
25,196 KB |
testcase_37 | AC | 24 ms
25,196 KB |
testcase_38 | AC | 27 ms
25,580 KB |
testcase_39 | AC | 24 ms
25,196 KB |
testcase_40 | AC | 23 ms
24,544 KB |
testcase_41 | AC | 24 ms
24,812 KB |
testcase_42 | AC | 24 ms
24,940 KB |
testcase_43 | AC | 24 ms
25,196 KB |
testcase_44 | AC | 27 ms
24,940 KB |
testcase_45 | AC | 25 ms
24,812 KB |
testcase_46 | AC | 26 ms
24,800 KB |
testcase_47 | AC | 28 ms
24,556 KB |
testcase_48 | AC | 29 ms
25,196 KB |
testcase_49 | AC | 31 ms
24,544 KB |
testcase_50 | AC | 32 ms
24,556 KB |
testcase_51 | AC | 34 ms
24,812 KB |
testcase_52 | AC | 38 ms
24,812 KB |
testcase_53 | AC | 41 ms
25,196 KB |
testcase_54 | AC | 41 ms
24,812 KB |
testcase_55 | AC | 46 ms
24,940 KB |
testcase_56 | AC | 51 ms
24,812 KB |
testcase_57 | AC | 54 ms
24,428 KB |
testcase_58 | AC | 61 ms
24,812 KB |
testcase_59 | AC | 64 ms
25,068 KB |
testcase_60 | AC | 76 ms
25,196 KB |
testcase_61 | AC | 93 ms
25,452 KB |
testcase_62 | AC | 93 ms
24,544 KB |
testcase_63 | AC | 101 ms
24,812 KB |
testcase_64 | AC | 106 ms
25,196 KB |
testcase_65 | AC | 118 ms
25,180 KB |
testcase_66 | AC | 138 ms
25,196 KB |
testcase_67 | AC | 147 ms
24,812 KB |
testcase_68 | AC | 155 ms
25,196 KB |
testcase_69 | AC | 177 ms
25,196 KB |
testcase_70 | AC | 192 ms
24,812 KB |
testcase_71 | AC | 211 ms
24,556 KB |
testcase_72 | AC | 231 ms
24,812 KB |
testcase_73 | AC | 250 ms
24,812 KB |
testcase_74 | AC | 285 ms
24,940 KB |
testcase_75 | AC | 299 ms
24,812 KB |
testcase_76 | AC | 334 ms
25,196 KB |
testcase_77 | AC | 374 ms
24,800 KB |
testcase_78 | AC | 403 ms
25,580 KB |
testcase_79 | AC | 454 ms
25,196 KB |
testcase_80 | AC | 481 ms
24,812 KB |
testcase_81 | AC | 502 ms
24,812 KB |
testcase_82 | AC | 572 ms
25,196 KB |
testcase_83 | AC | 658 ms
25,196 KB |
testcase_84 | AC | 673 ms
25,196 KB |
testcase_85 | AC | 771 ms
24,556 KB |
testcase_86 | AC | 658 ms
24,812 KB |
testcase_87 | AC | 722 ms
25,196 KB |
testcase_88 | AC | 798 ms
24,556 KB |
testcase_89 | AC | 657 ms
24,812 KB |
testcase_90 | AC | 763 ms
24,812 KB |
testcase_91 | AC | 608 ms
24,940 KB |
testcase_92 | AC | 707 ms
24,812 KB |
testcase_93 | AC | 670 ms
25,196 KB |
testcase_94 | AC | 597 ms
24,556 KB |
testcase_95 | AC | 646 ms
25,124 KB |
testcase_96 | AC | 592 ms
25,196 KB |
testcase_97 | AC | 704 ms
25,196 KB |
testcase_98 | AC | 602 ms
25,196 KB |
testcase_99 | AC | 605 ms
25,196 KB |
testcase_100 | AC | 619 ms
25,196 KB |
testcase_101 | AC | 659 ms
24,812 KB |
testcase_102 | AC | 599 ms
24,812 KB |
testcase_103 | AC | 614 ms
24,812 KB |
testcase_104 | AC | 645 ms
24,812 KB |
testcase_105 | AC | 751 ms
24,940 KB |
testcase_106 | AC | 631 ms
25,196 KB |
testcase_107 | AC | 772 ms
24,556 KB |
testcase_108 | AC | 748 ms
24,812 KB |
testcase_109 | AC | 793 ms
24,800 KB |
testcase_110 | AC | 642 ms
24,812 KB |
testcase_111 | AC | 777 ms
24,556 KB |
testcase_112 | AC | 602 ms
24,556 KB |
testcase_113 | AC | 779 ms
25,068 KB |
testcase_114 | AC | 738 ms
25,196 KB |
testcase_115 | AC | 702 ms
25,068 KB |
testcase_116 | AC | 802 ms
25,196 KB |
testcase_117 | AC | 720 ms
24,812 KB |
testcase_118 | AC | 768 ms
24,812 KB |
testcase_119 | AC | 746 ms
25,196 KB |
testcase_120 | AC | 644 ms
24,812 KB |
testcase_121 | AC | 666 ms
24,940 KB |
testcase_122 | AC | 651 ms
25,196 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; auto pl = mp.begin()->first; if (pl.first != pl.second && (pi != 0 || pj != 0)) { 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; }