結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | ei1333333 |
提出日時 | 2020-12-05 00:54:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,075 bytes |
コンパイル時間 | 2,570 ms |
コンパイル使用メモリ | 219,968 KB |
実行使用メモリ | 25,812 KB |
平均クエリ数 | 1226.98 |
最終ジャッジ日時 | 2024-07-17 09:42:19 |
合計ジャッジ時間 | 33,808 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
24,940 KB |
testcase_01 | RE | - |
testcase_02 | AC | 23 ms
25,220 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | AC | 23 ms
24,824 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 23 ms
24,580 KB |
testcase_10 | AC | 25 ms
25,220 KB |
testcase_11 | AC | 24 ms
25,220 KB |
testcase_12 | AC | 24 ms
24,964 KB |
testcase_13 | AC | 24 ms
24,940 KB |
testcase_14 | AC | 23 ms
25,196 KB |
testcase_15 | AC | 23 ms
24,556 KB |
testcase_16 | AC | 22 ms
24,812 KB |
testcase_17 | AC | 23 ms
25,196 KB |
testcase_18 | AC | 23 ms
25,196 KB |
testcase_19 | AC | 23 ms
24,812 KB |
testcase_20 | AC | 23 ms
24,812 KB |
testcase_21 | AC | 23 ms
24,556 KB |
testcase_22 | AC | 23 ms
25,196 KB |
testcase_23 | AC | 23 ms
25,196 KB |
testcase_24 | AC | 23 ms
24,812 KB |
testcase_25 | AC | 24 ms
24,812 KB |
testcase_26 | AC | 24 ms
25,184 KB |
testcase_27 | AC | 24 ms
24,940 KB |
testcase_28 | AC | 23 ms
24,940 KB |
testcase_29 | AC | 22 ms
24,940 KB |
testcase_30 | AC | 23 ms
24,812 KB |
testcase_31 | AC | 24 ms
24,556 KB |
testcase_32 | AC | 23 ms
24,556 KB |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | AC | 24 ms
24,556 KB |
testcase_36 | RE | - |
testcase_37 | AC | 24 ms
24,812 KB |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | AC | 24 ms
25,196 KB |
testcase_43 | AC | 26 ms
24,940 KB |
testcase_44 | AC | 26 ms
24,812 KB |
testcase_45 | AC | 26 ms
25,196 KB |
testcase_46 | AC | 26 ms
25,196 KB |
testcase_47 | AC | 27 ms
24,812 KB |
testcase_48 | AC | 28 ms
25,196 KB |
testcase_49 | AC | 29 ms
25,196 KB |
testcase_50 | RE | - |
testcase_51 | AC | 32 ms
25,196 KB |
testcase_52 | AC | 34 ms
24,940 KB |
testcase_53 | AC | 35 ms
24,812 KB |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | AC | 46 ms
24,928 KB |
testcase_57 | AC | 48 ms
24,812 KB |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | AC | 49 ms
24,556 KB |
testcase_61 | AC | 58 ms
24,812 KB |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | AC | 53 ms
24,800 KB |
testcase_65 | AC | 70 ms
25,196 KB |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | AC | 97 ms
24,556 KB |
testcase_69 | AC | 91 ms
25,196 KB |
testcase_70 | AC | 145 ms
25,196 KB |
testcase_71 | RE | - |
testcase_72 | AC | 134 ms
24,812 KB |
testcase_73 | AC | 155 ms
24,812 KB |
testcase_74 | AC | 110 ms
24,940 KB |
testcase_75 | RE | - |
testcase_76 | AC | 183 ms
24,940 KB |
testcase_77 | AC | 213 ms
25,196 KB |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | AC | 204 ms
24,796 KB |
testcase_81 | AC | 273 ms
24,940 KB |
testcase_82 | RE | - |
testcase_83 | AC | 191 ms
25,196 KB |
testcase_84 | AC | 196 ms
24,556 KB |
testcase_85 | RE | - |
testcase_86 | AC | 243 ms
24,940 KB |
testcase_87 | AC | 280 ms
24,812 KB |
testcase_88 | RE | - |
testcase_89 | AC | 369 ms
24,940 KB |
testcase_90 | RE | - |
testcase_91 | RE | - |
testcase_92 | AC | 339 ms
24,812 KB |
testcase_93 | AC | 296 ms
24,556 KB |
testcase_94 | RE | - |
testcase_95 | AC | 337 ms
24,812 KB |
testcase_96 | RE | - |
testcase_97 | AC | 174 ms
24,812 KB |
testcase_98 | RE | - |
testcase_99 | RE | - |
testcase_100 | AC | 341 ms
24,556 KB |
testcase_101 | AC | 438 ms
24,556 KB |
testcase_102 | AC | 297 ms
24,812 KB |
testcase_103 | RE | - |
testcase_104 | AC | 238 ms
24,940 KB |
testcase_105 | RE | - |
testcase_106 | AC | 401 ms
24,812 KB |
testcase_107 | RE | - |
testcase_108 | RE | - |
testcase_109 | RE | - |
testcase_110 | AC | 142 ms
25,196 KB |
testcase_111 | RE | - |
testcase_112 | AC | 135 ms
24,556 KB |
testcase_113 | RE | - |
testcase_114 | AC | 150 ms
24,940 KB |
testcase_115 | AC | 249 ms
25,196 KB |
testcase_116 | RE | - |
testcase_117 | AC | 373 ms
25,196 KB |
testcase_118 | RE | - |
testcase_119 | RE | - |
testcase_120 | AC | 154 ms
24,812 KB |
testcase_121 | AC | 238 ms
24,812 KB |
testcase_122 | AC | 188 ms
24,940 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 < M; 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; } } //assert(~y); 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; }