結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | hitonanode |
提出日時 | 2020-12-03 01:21:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,929 bytes |
コンパイル時間 | 2,581 ms |
コンパイル使用メモリ | 224,716 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 07:56:33 |
合計ジャッジ時間 | 17,048 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
25,196 KB |
testcase_01 | AC | 25 ms
24,940 KB |
testcase_02 | AC | 23 ms
25,220 KB |
testcase_03 | AC | 22 ms
24,580 KB |
testcase_04 | AC | 22 ms
24,580 KB |
testcase_05 | AC | 22 ms
24,964 KB |
testcase_06 | AC | 22 ms
25,220 KB |
testcase_07 | AC | 22 ms
25,220 KB |
testcase_08 | AC | 23 ms
24,836 KB |
testcase_09 | AC | 22 ms
24,836 KB |
testcase_10 | AC | 22 ms
25,160 KB |
testcase_11 | AC | 22 ms
24,836 KB |
testcase_12 | WA | - |
testcase_13 | AC | 22 ms
24,556 KB |
testcase_14 | AC | 23 ms
24,940 KB |
testcase_15 | AC | 23 ms
24,940 KB |
testcase_16 | AC | 22 ms
24,556 KB |
testcase_17 | AC | 22 ms
24,940 KB |
testcase_18 | WA | - |
testcase_19 | AC | 23 ms
24,556 KB |
testcase_20 | AC | 23 ms
24,812 KB |
testcase_21 | AC | 22 ms
24,556 KB |
testcase_22 | AC | 23 ms
25,196 KB |
testcase_23 | AC | 22 ms
24,812 KB |
testcase_24 | WA | - |
testcase_25 | AC | 23 ms
25,196 KB |
testcase_26 | AC | 23 ms
24,940 KB |
testcase_27 | WA | - |
testcase_28 | AC | 22 ms
24,556 KB |
testcase_29 | AC | 22 ms
24,940 KB |
testcase_30 | AC | 25 ms
24,556 KB |
testcase_31 | AC | 23 ms
24,812 KB |
testcase_32 | AC | 22 ms
25,196 KB |
testcase_33 | AC | 22 ms
24,556 KB |
testcase_34 | AC | 22 ms
24,812 KB |
testcase_35 | AC | 23 ms
25,196 KB |
testcase_36 | AC | 23 ms
25,196 KB |
testcase_37 | AC | 22 ms
25,196 KB |
testcase_38 | AC | 23 ms
25,196 KB |
testcase_39 | AC | 23 ms
24,556 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 24 ms
25,196 KB |
testcase_43 | AC | 23 ms
24,812 KB |
testcase_44 | WA | - |
testcase_45 | AC | 25 ms
24,940 KB |
testcase_46 | AC | 26 ms
24,556 KB |
testcase_47 | AC | 26 ms
25,196 KB |
testcase_48 | AC | 27 ms
24,940 KB |
testcase_49 | AC | 29 ms
25,196 KB |
testcase_50 | AC | 29 ms
24,556 KB |
testcase_51 | AC | 33 ms
25,196 KB |
testcase_52 | AC | 31 ms
24,812 KB |
testcase_53 | AC | 35 ms
25,196 KB |
testcase_54 | AC | 33 ms
25,240 KB |
testcase_55 | AC | 36 ms
24,812 KB |
testcase_56 | AC | 39 ms
24,812 KB |
testcase_57 | AC | 38 ms
24,940 KB |
testcase_58 | AC | 41 ms
25,196 KB |
testcase_59 | AC | 40 ms
24,812 KB |
testcase_60 | AC | 47 ms
24,812 KB |
testcase_61 | AC | 51 ms
25,196 KB |
testcase_62 | AC | 50 ms
24,428 KB |
testcase_63 | AC | 54 ms
25,168 KB |
testcase_64 | AC | 51 ms
25,112 KB |
testcase_65 | AC | 54 ms
25,196 KB |
testcase_66 | AC | 60 ms
24,940 KB |
testcase_67 | AC | 62 ms
24,812 KB |
testcase_68 | AC | 62 ms
24,812 KB |
testcase_69 | AC | 65 ms
24,556 KB |
testcase_70 | AC | 66 ms
24,812 KB |
testcase_71 | AC | 69 ms
25,196 KB |
testcase_72 | AC | 70 ms
24,812 KB |
testcase_73 | AC | 68 ms
24,812 KB |
testcase_74 | AC | 79 ms
24,940 KB |
testcase_75 | AC | 76 ms
24,812 KB |
testcase_76 | AC | 86 ms
25,184 KB |
testcase_77 | AC | 93 ms
24,428 KB |
testcase_78 | AC | 98 ms
24,812 KB |
testcase_79 | AC | 106 ms
24,556 KB |
testcase_80 | AC | 108 ms
24,812 KB |
testcase_81 | AC | 91 ms
24,556 KB |
testcase_82 | AC | 114 ms
24,556 KB |
testcase_83 | AC | 116 ms
25,196 KB |
testcase_84 | AC | 124 ms
25,196 KB |
testcase_85 | AC | 131 ms
25,196 KB |
testcase_86 | AC | 110 ms
24,812 KB |
testcase_87 | AC | 114 ms
24,812 KB |
testcase_88 | WA | - |
testcase_89 | AC | 118 ms
24,556 KB |
testcase_90 | AC | 103 ms
24,940 KB |
testcase_91 | AC | 112 ms
24,796 KB |
testcase_92 | AC | 104 ms
24,940 KB |
testcase_93 | AC | 121 ms
25,196 KB |
testcase_94 | AC | 104 ms
24,940 KB |
testcase_95 | AC | 111 ms
24,812 KB |
testcase_96 | AC | 101 ms
24,556 KB |
testcase_97 | AC | 101 ms
25,196 KB |
testcase_98 | AC | 97 ms
24,812 KB |
testcase_99 | AC | 114 ms
24,812 KB |
testcase_100 | AC | 114 ms
24,812 KB |
testcase_101 | AC | 123 ms
25,196 KB |
testcase_102 | AC | 103 ms
24,556 KB |
testcase_103 | AC | 109 ms
25,196 KB |
testcase_104 | AC | 109 ms
25,196 KB |
testcase_105 | AC | 112 ms
25,184 KB |
testcase_106 | AC | 98 ms
24,556 KB |
testcase_107 | AC | 113 ms
24,812 KB |
testcase_108 | AC | 106 ms
24,940 KB |
testcase_109 | AC | 126 ms
25,196 KB |
testcase_110 | AC | 104 ms
25,196 KB |
testcase_111 | AC | 106 ms
24,556 KB |
testcase_112 | AC | 96 ms
24,940 KB |
testcase_113 | AC | 131 ms
24,940 KB |
testcase_114 | AC | 134 ms
24,556 KB |
testcase_115 | AC | 113 ms
24,812 KB |
testcase_116 | AC | 135 ms
24,556 KB |
testcase_117 | AC | 114 ms
24,812 KB |
testcase_118 | AC | 124 ms
24,940 KB |
testcase_119 | AC | 106 ms
25,196 KB |
testcase_120 | AC | 97 ms
24,556 KB |
testcase_121 | AC | 119 ms
24,556 KB |
testcase_122 | AC | 116 ms
24,556 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; using pint = pair<int, int>; using plint = pair<lint, lint>; struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template <typename T, typename V> void ndarray(vector<T>& vec, const V& val, int len) { vec.assign(len, val); } template <typename T, typename V, typename... Args> void ndarray(vector<T>& vec, const V& val, int len, Args... args) { vec.resize(len), for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); }); } template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } int floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } template <typename T> vector<T> sort_unique(vector<T> vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; } #if __cplusplus >= 201703L template <typename... T> istream &operator>>(istream &is, tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; } template <typename... T> ostream &operator<<(ostream &os, const tuple<T...> &tpl) { std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os; } #endif template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template <typename T, typename TH> ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; } template <typename TK, typename TV, typename TH> ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; } #ifdef HITONANODE_LOCAL #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl #else #define dbg(x) {} #endif pint query(int i, int j) { cout << "? " << i + 1 << ' ' << j + 1 << endl; int x, y; cin >> x >> y; return make_pair(x, y); } pint simulate(pint pi, pint pj) { pint ret = pi - pj; if (ret.first > ret.second) swap(ret.first, ret.second); return ret; } int main() { int N; cin >> N; const int L = N * N - N; vector<pint> ans(L); map<int, int> mp; map<pint, vector<int>> p2i; mp[0] += 2; FOR(i, 1, L) { ans[i] = query(i, 0); p2i[ans[i]].emplace_back(i); if (ans[i].first * ans[i].second == 0) mp[ans[i].first + ans[i].second]++; } const int lo = mp.begin()->first; const int hi = prev(mp.end())->first; int lo2 = lo, hi2 = hi; while (mp[lo2] == 1) lo2++; while (mp[hi2] == 1) hi2--; int d1 = hi2 - lo, d2 = hi - lo2; vector<pint> ret(L, pint(-1, -1)); if (hi2 - lo == N - 1 and hi - lo2 == N - 2) { ret[0] = make_pair(-lo2 + 1, -lo); // (十, 一) } else if (hi2 - lo == N - 2 and hi - lo2 == N - 1) { ret[0] = make_pair(-lo + 1, -lo2); } else { exit(8); } int ic = -1; for (const auto [p, is] : p2i) { pint pa = p; if (is.size() == 1) { int i = is[0]; pint pcand = ret[0] + pa; if (pcand.first >= 1 and pcand.first < N and pcand.second >= 0 and pcand.second < N) ret[i] = pcand; else { swap(pa.first, pa.second); ret[i] = ret[0] + pa; } ic = i; } } assert(ic != -1); for (const auto [p, is] : p2i) { if (is.size() == 2) { pint pa = p; int i = is[0], j = is[1]; pint p1 = ret[0] + pa; swap(pa.first, pa.second); pint p2 = ret[0] + pa; pint ptmp = query(i, ic); pint pc1 = ret[ic] + ptmp; swap(ptmp.first, ptmp.second); pint pc2 = ret[ic] + ptmp; if (p1 == pc1 or p1 == pc2) ret[i] = p1, ret[j] = p2; else ret[i] = p2, ret[j] = p1; } } cout << "! "; for (auto x : ret) cout << x.first * N + x.second << ' '; cout << endl; }