結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | pes_magic |
提出日時 | 2020-12-15 22:25:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,266 bytes |
コンパイル時間 | 755 ms |
コンパイル使用メモリ | 83,824 KB |
最終ジャッジ日時 | 2025-01-17 01:14:41 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
25,576 KB |
testcase_01 | AC | 20 ms
25,948 KB |
testcase_02 | AC | 19 ms
25,984 KB |
testcase_03 | AC | 19 ms
25,460 KB |
testcase_04 | AC | 18 ms
25,332 KB |
testcase_05 | AC | 19 ms
25,460 KB |
testcase_06 | AC | 19 ms
25,588 KB |
testcase_07 | AC | 18 ms
25,572 KB |
testcase_08 | AC | 18 ms
25,972 KB |
testcase_09 | AC | 19 ms
25,332 KB |
testcase_10 | AC | 20 ms
25,460 KB |
testcase_11 | WA | - |
testcase_12 | AC | 19 ms
25,600 KB |
testcase_13 | AC | 22 ms
25,960 KB |
testcase_14 | WA | - |
testcase_15 | AC | 20 ms
25,576 KB |
testcase_16 | AC | 21 ms
25,832 KB |
testcase_17 | AC | 21 ms
25,948 KB |
testcase_18 | AC | 19 ms
26,216 KB |
testcase_19 | AC | 20 ms
25,192 KB |
testcase_20 | AC | 19 ms
25,064 KB |
testcase_21 | AC | 19 ms
25,832 KB |
testcase_22 | AC | 20 ms
25,436 KB |
testcase_23 | AC | 21 ms
25,960 KB |
testcase_24 | AC | 20 ms
25,320 KB |
testcase_25 | AC | 19 ms
25,948 KB |
testcase_26 | AC | 19 ms
25,576 KB |
testcase_27 | AC | 20 ms
25,948 KB |
testcase_28 | AC | 20 ms
25,588 KB |
testcase_29 | AC | 22 ms
26,216 KB |
testcase_30 | AC | 20 ms
25,192 KB |
testcase_31 | AC | 22 ms
25,948 KB |
testcase_32 | AC | 19 ms
25,448 KB |
testcase_33 | AC | 21 ms
26,216 KB |
testcase_34 | AC | 20 ms
25,320 KB |
testcase_35 | AC | 20 ms
25,320 KB |
testcase_36 | AC | 20 ms
25,960 KB |
testcase_37 | AC | 21 ms
25,832 KB |
testcase_38 | AC | 21 ms
25,948 KB |
testcase_39 | AC | 21 ms
26,516 KB |
testcase_40 | AC | 20 ms
25,960 KB |
testcase_41 | AC | 20 ms
25,040 KB |
testcase_42 | AC | 20 ms
25,960 KB |
testcase_43 | AC | 21 ms
25,576 KB |
testcase_44 | AC | 21 ms
25,960 KB |
testcase_45 | AC | 20 ms
25,192 KB |
testcase_46 | AC | 23 ms
25,960 KB |
testcase_47 | AC | 23 ms
25,448 KB |
testcase_48 | AC | 23 ms
25,192 KB |
testcase_49 | AC | 24 ms
26,188 KB |
testcase_50 | AC | 25 ms
25,576 KB |
testcase_51 | AC | 26 ms
25,576 KB |
testcase_52 | AC | 28 ms
25,832 KB |
testcase_53 | AC | 29 ms
25,948 KB |
testcase_54 | AC | 28 ms
25,960 KB |
testcase_55 | AC | 31 ms
25,960 KB |
testcase_56 | AC | 32 ms
25,320 KB |
testcase_57 | AC | 32 ms
26,216 KB |
testcase_58 | AC | 34 ms
25,960 KB |
testcase_59 | AC | 34 ms
25,960 KB |
testcase_60 | AC | 40 ms
25,576 KB |
testcase_61 | AC | 44 ms
25,576 KB |
testcase_62 | AC | 42 ms
25,448 KB |
testcase_63 | AC | 46 ms
25,576 KB |
testcase_64 | AC | 44 ms
25,832 KB |
testcase_65 | AC | 48 ms
25,576 KB |
testcase_66 | AC | 52 ms
25,192 KB |
testcase_67 | AC | 53 ms
25,948 KB |
testcase_68 | AC | 51 ms
26,216 KB |
testcase_69 | AC | 56 ms
25,280 KB |
testcase_70 | AC | 57 ms
25,052 KB |
testcase_71 | AC | 61 ms
25,448 KB |
testcase_72 | AC | 61 ms
25,448 KB |
testcase_73 | AC | 58 ms
25,064 KB |
testcase_74 | AC | 68 ms
25,320 KB |
testcase_75 | AC | 63 ms
25,948 KB |
testcase_76 | AC | 73 ms
25,320 KB |
testcase_77 | AC | 79 ms
26,216 KB |
testcase_78 | AC | 84 ms
25,960 KB |
testcase_79 | AC | 93 ms
26,200 KB |
testcase_80 | AC | 95 ms
25,948 KB |
testcase_81 | AC | 77 ms
25,448 KB |
testcase_82 | AC | 97 ms
26,188 KB |
testcase_83 | AC | 98 ms
26,216 KB |
testcase_84 | AC | 106 ms
25,192 KB |
testcase_85 | AC | 112 ms
25,948 KB |
testcase_86 | AC | 94 ms
25,576 KB |
testcase_87 | AC | 97 ms
26,216 KB |
testcase_88 | AC | 119 ms
25,320 KB |
testcase_89 | AC | 101 ms
25,948 KB |
testcase_90 | AC | 89 ms
26,216 KB |
testcase_91 | AC | 100 ms
25,320 KB |
testcase_92 | AC | 91 ms
25,960 KB |
testcase_93 | AC | 109 ms
25,192 KB |
testcase_94 | AC | 89 ms
25,832 KB |
testcase_95 | AC | 95 ms
25,960 KB |
testcase_96 | AC | 86 ms
25,192 KB |
testcase_97 | AC | 86 ms
25,052 KB |
testcase_98 | AC | 84 ms
25,820 KB |
testcase_99 | AC | 96 ms
25,948 KB |
testcase_100 | AC | 98 ms
25,832 KB |
testcase_101 | AC | 105 ms
25,448 KB |
testcase_102 | AC | 87 ms
25,576 KB |
testcase_103 | AC | 94 ms
25,572 KB |
testcase_104 | AC | 97 ms
25,960 KB |
testcase_105 | AC | 95 ms
25,320 KB |
testcase_106 | AC | 84 ms
26,216 KB |
testcase_107 | AC | 97 ms
25,320 KB |
testcase_108 | AC | 87 ms
25,960 KB |
testcase_109 | AC | 105 ms
25,948 KB |
testcase_110 | AC | 86 ms
26,216 KB |
testcase_111 | AC | 97 ms
25,948 KB |
testcase_112 | AC | 90 ms
25,960 KB |
testcase_113 | AC | 114 ms
25,960 KB |
testcase_114 | AC | 112 ms
26,216 KB |
testcase_115 | AC | 96 ms
25,832 KB |
testcase_116 | AC | 119 ms
25,960 KB |
testcase_117 | AC | 100 ms
25,948 KB |
testcase_118 | AC | 109 ms
25,948 KB |
testcase_119 | AC | 90 ms
25,960 KB |
testcase_120 | AC | 86 ms
26,216 KB |
testcase_121 | AC | 100 ms
26,216 KB |
testcase_122 | AC | 100 ms
25,960 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int N; cin >> N; vector<pair<int, int>> dif(N*(N-1)); dif[0] = make_pair(0, 0); for(int i=1;i<dif.size();i++){ cout << "? " << i+1 << " " << 1 << endl; cin >> dif[i].first >> dif[i].second; } vector<int> res(N*(N-1), -1); vector<vector<int>> use(N, vector<int>(N, 0)); for(int i=0;i<N;i++) use[0][i] = 1; auto minIdx = distance(dif.begin(), min_element(dif.begin(), dif.end())); auto maxIdx = distance(dif.begin(), max_element(dif.begin(), dif.end())); res[maxIdx] = (N-1)*N+N-1; use[N-1][N-1] = 1; res[minIdx] = N; use[1][0] = 1; for(int i=1;i<N;i++){ if(res[0] != -1) break; for(int j=0;j<N;j++){ if(use[i][j]) continue; int p1 = 1-i, q1 = -j; if(p1 > q1) swap(p1, q1); int p2 = N-1-i, q2 = N-1-j; if(p2 > q2) swap(p2, q2); if(dif[minIdx] == make_pair(p1, q1) && dif[maxIdx] == make_pair(p2, q2)){ res[0] = i*N+j; use[i][j] = 1; break; } } } int a0 = res[0]/N, b0 = res[0]%N; for(int i=1;i<dif.size();i++){ if(res[i] != -1) continue; vector<pair<int, int>> cand; int p = dif[i].first + a0, q = dif[i].second + b0; if(1 <= p && p <= N-1 && 0 <= q && q <= N-1 && !use[p][q]) cand.emplace_back(p, q); p = dif[i].second + a0, q = dif[i].first + b0; if(1 <= p && p <= N-1 && 0 <= q && q <= N-1 && !use[p][q]) cand.emplace_back(p, q); if(cand.size() == 2 && cand[0] == cand[1]) cand.pop_back(); if(cand.size() == 2){ int target = (minIdx == 0 ? maxIdx : minIdx); cout << "? " << i+1 << " " << target+1 << endl; int p, q; cin >> p >> q; int pc = cand[0].first - res[target]/N; int qc = cand[0].second - res[target]%N; if(pc > qc) swap(pc, qc); if(p != pc || q != qc) swap(cand[0], cand[1]); } res[i] = cand[0].first * N + cand[0].second; use[cand[0].first][cand[0].second] = 1; } cout << "!"; for(auto& t : res) cout << " " << t; cout << endl; }