結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | ei1333333 |
提出日時 | 2020-12-05 00:56:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 566 ms / 2,000 ms |
コード長 | 4,064 bytes |
コンパイル時間 | 2,457 ms |
コンパイル使用メモリ | 221,096 KB |
実行使用メモリ | 25,452 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 09:45:40 |
合計ジャッジ時間 | 24,920 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
24,940 KB |
testcase_01 | AC | 22 ms
24,940 KB |
testcase_02 | AC | 22 ms
24,836 KB |
testcase_03 | AC | 22 ms
25,220 KB |
testcase_04 | AC | 22 ms
25,220 KB |
testcase_05 | AC | 23 ms
25,220 KB |
testcase_06 | AC | 22 ms
24,836 KB |
testcase_07 | AC | 22 ms
24,964 KB |
testcase_08 | AC | 23 ms
24,580 KB |
testcase_09 | AC | 22 ms
24,964 KB |
testcase_10 | AC | 23 ms
25,220 KB |
testcase_11 | AC | 23 ms
24,580 KB |
testcase_12 | AC | 23 ms
25,220 KB |
testcase_13 | AC | 23 ms
24,556 KB |
testcase_14 | AC | 22 ms
24,556 KB |
testcase_15 | AC | 22 ms
25,196 KB |
testcase_16 | AC | 22 ms
24,556 KB |
testcase_17 | AC | 23 ms
24,812 KB |
testcase_18 | AC | 23 ms
24,940 KB |
testcase_19 | AC | 23 ms
24,812 KB |
testcase_20 | AC | 23 ms
24,812 KB |
testcase_21 | AC | 23 ms
25,440 KB |
testcase_22 | AC | 22 ms
24,940 KB |
testcase_23 | AC | 22 ms
24,928 KB |
testcase_24 | AC | 24 ms
24,812 KB |
testcase_25 | AC | 22 ms
24,556 KB |
testcase_26 | AC | 23 ms
24,812 KB |
testcase_27 | AC | 23 ms
24,812 KB |
testcase_28 | AC | 23 ms
24,556 KB |
testcase_29 | AC | 23 ms
24,556 KB |
testcase_30 | AC | 23 ms
25,184 KB |
testcase_31 | AC | 22 ms
24,940 KB |
testcase_32 | AC | 23 ms
24,928 KB |
testcase_33 | AC | 23 ms
24,940 KB |
testcase_34 | AC | 23 ms
25,452 KB |
testcase_35 | AC | 24 ms
24,812 KB |
testcase_36 | AC | 23 ms
24,928 KB |
testcase_37 | AC | 23 ms
24,556 KB |
testcase_38 | AC | 24 ms
25,196 KB |
testcase_39 | AC | 23 ms
24,556 KB |
testcase_40 | AC | 24 ms
24,556 KB |
testcase_41 | AC | 23 ms
24,812 KB |
testcase_42 | AC | 23 ms
24,940 KB |
testcase_43 | AC | 23 ms
25,196 KB |
testcase_44 | AC | 24 ms
24,940 KB |
testcase_45 | AC | 25 ms
25,436 KB |
testcase_46 | AC | 25 ms
24,812 KB |
testcase_47 | AC | 26 ms
24,812 KB |
testcase_48 | AC | 28 ms
24,940 KB |
testcase_49 | AC | 28 ms
25,196 KB |
testcase_50 | AC | 29 ms
25,452 KB |
testcase_51 | AC | 31 ms
24,812 KB |
testcase_52 | AC | 34 ms
24,940 KB |
testcase_53 | AC | 34 ms
25,196 KB |
testcase_54 | AC | 37 ms
24,940 KB |
testcase_55 | AC | 38 ms
24,812 KB |
testcase_56 | AC | 45 ms
24,812 KB |
testcase_57 | AC | 44 ms
24,940 KB |
testcase_58 | AC | 42 ms
25,196 KB |
testcase_59 | AC | 54 ms
24,812 KB |
testcase_60 | AC | 48 ms
24,940 KB |
testcase_61 | AC | 57 ms
24,940 KB |
testcase_62 | AC | 62 ms
24,812 KB |
testcase_63 | AC | 73 ms
25,196 KB |
testcase_64 | AC | 53 ms
24,940 KB |
testcase_65 | AC | 71 ms
24,812 KB |
testcase_66 | AC | 66 ms
24,940 KB |
testcase_67 | AC | 67 ms
25,196 KB |
testcase_68 | AC | 97 ms
25,196 KB |
testcase_69 | AC | 90 ms
24,812 KB |
testcase_70 | AC | 144 ms
24,556 KB |
testcase_71 | AC | 82 ms
24,812 KB |
testcase_72 | AC | 133 ms
25,196 KB |
testcase_73 | AC | 155 ms
25,196 KB |
testcase_74 | AC | 109 ms
25,196 KB |
testcase_75 | AC | 169 ms
25,196 KB |
testcase_76 | AC | 182 ms
24,940 KB |
testcase_77 | AC | 213 ms
24,940 KB |
testcase_78 | AC | 145 ms
25,436 KB |
testcase_79 | AC | 272 ms
24,812 KB |
testcase_80 | AC | 206 ms
24,940 KB |
testcase_81 | AC | 270 ms
25,196 KB |
testcase_82 | AC | 246 ms
24,812 KB |
testcase_83 | AC | 191 ms
25,196 KB |
testcase_84 | AC | 196 ms
25,180 KB |
testcase_85 | AC | 322 ms
25,196 KB |
testcase_86 | AC | 242 ms
24,812 KB |
testcase_87 | AC | 285 ms
24,556 KB |
testcase_88 | AC | 236 ms
24,556 KB |
testcase_89 | AC | 370 ms
24,812 KB |
testcase_90 | AC | 503 ms
24,556 KB |
testcase_91 | AC | 413 ms
24,812 KB |
testcase_92 | AC | 342 ms
24,812 KB |
testcase_93 | AC | 299 ms
24,940 KB |
testcase_94 | AC | 137 ms
24,940 KB |
testcase_95 | AC | 340 ms
24,812 KB |
testcase_96 | AC | 353 ms
24,812 KB |
testcase_97 | AC | 172 ms
24,812 KB |
testcase_98 | AC | 131 ms
24,796 KB |
testcase_99 | AC | 298 ms
24,812 KB |
testcase_100 | AC | 340 ms
24,556 KB |
testcase_101 | AC | 442 ms
24,940 KB |
testcase_102 | AC | 299 ms
25,196 KB |
testcase_103 | AC | 297 ms
24,812 KB |
testcase_104 | AC | 239 ms
25,196 KB |
testcase_105 | AC | 365 ms
24,940 KB |
testcase_106 | AC | 402 ms
24,812 KB |
testcase_107 | AC | 312 ms
24,928 KB |
testcase_108 | AC | 453 ms
24,940 KB |
testcase_109 | AC | 165 ms
25,196 KB |
testcase_110 | AC | 145 ms
25,196 KB |
testcase_111 | AC | 140 ms
24,812 KB |
testcase_112 | AC | 136 ms
24,940 KB |
testcase_113 | AC | 295 ms
25,064 KB |
testcase_114 | AC | 149 ms
24,940 KB |
testcase_115 | AC | 250 ms
24,556 KB |
testcase_116 | AC | 566 ms
24,556 KB |
testcase_117 | AC | 373 ms
24,556 KB |
testcase_118 | AC | 549 ms
24,812 KB |
testcase_119 | AC | 389 ms
24,812 KB |
testcase_120 | AC | 154 ms
24,556 KB |
testcase_121 | AC | 242 ms
25,196 KB |
testcase_122 | AC | 189 ms
24,812 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; const int mod = 1e9 + 7; // const int mod = 998244353; const int64 infll = (1LL << 62) - 1; const int inf = (1 << 30) - 1; struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup; template< typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 > &p) { os << p.first << " " << p.second; return os; } template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; } template< typename T > ostream &operator<<(ostream &os, const vector< T > &v) { for(int i = 0; i < (int) v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; } template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template< typename T = int64 > vector< T > make_v(size_t a) { return vector< T >(a); } template< typename T, typename... Ts > auto make_v(size_t a, Ts... ts) { return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...)); } template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; } template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); } template< typename F > struct FixPoint : F { FixPoint(F &&f) : F(forward< F >(f)) {} template< typename... Args > decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, forward< Args >(args)...); } }; template< typename F > inline decltype(auto) MFP(F &&f) { return FixPoint< F >{forward< F >(f)}; } pair< int, int > ask(int x, int y) { cout << "? " << x << " " << y << endl; int p, q; cin >> p >> q; return {p, q}; } int main() { int N; cin >> N; int M = N * N - N; vector< int > ans(M, -1); auto f = [&](int a, int b) { int x = a / N - b / N; int y = a % N - b % N; if(x > y) swap(x, y); return make_pair(x, y); }; vector< pair< int, int > > ret; for(int i = 1; i < M; i++) { ret.emplace_back(ask(1, i + 1)); } { auto xs{ret}; sort(begin(xs), end(xs)); for(int i = 0; i < M; i++) { vector< pair< int, int > > X; for(int j = 0; j < M; j++) { if(i == j) continue; X.emplace_back(f(i + N, j + N)); } sort(begin(X), end(X)); if(X == xs) { ans[0] = i + N; break; } } } map< int, vector< int > > mp; for(int i = 0; i < ret.size(); i++) { for(int j = 0; j < M; j++) { if(ret[i] == f(ans[0], j + N)) { mp[j + N].emplace_back(i + 1); break; } } } while(mp.size()) { auto it = begin(mp); while(it != end(mp)) { if(it->second.size() == 1) { ans[it->second.front()] = it->first; it = mp.erase(it); continue; } int x = it->first; int y = -1; for(int i = x + 1; i < N * N; i++) { if(f(ans[0], x) == f(ans[0], i)) { y = i; break; } } bool check = false; for(int i = 0; i < M; i++) { if(ans[i] == -1) continue; if(f(ans[i], x) != f(ans[i], y)) { auto beet = ask(i + 1, it->second.front() + 1); if(beet == f(ans[i], x)) { ans[it->second.front()] = x; ans[it->second.back()] = y; } else { ans[it->second.front()] = y; ans[it->second.back()] = x; } check = true; break; } } if(check) { it = mp.erase(it); } else { ++it; } } } cout << "! " << ans << endl; }