結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | hitonanode |
提出日時 | 2020-12-03 01:10:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,509 bytes |
コンパイル時間 | 2,707 ms |
コンパイル使用メモリ | 224,092 KB |
実行使用メモリ | 25,836 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 07:53:56 |
合計ジャッジ時間 | 27,015 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
25,196 KB |
testcase_01 | AC | 25 ms
24,812 KB |
testcase_02 | AC | 25 ms
24,836 KB |
testcase_03 | AC | 25 ms
25,220 KB |
testcase_04 | AC | 25 ms
24,836 KB |
testcase_05 | AC | 24 ms
24,964 KB |
testcase_06 | AC | 25 ms
24,964 KB |
testcase_07 | AC | 25 ms
25,220 KB |
testcase_08 | AC | 25 ms
24,836 KB |
testcase_09 | AC | 25 ms
24,824 KB |
testcase_10 | AC | 25 ms
24,820 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 25 ms
24,556 KB |
testcase_14 | WA | - |
testcase_15 | AC | 25 ms
24,556 KB |
testcase_16 | AC | 25 ms
24,812 KB |
testcase_17 | AC | 25 ms
25,196 KB |
testcase_18 | WA | - |
testcase_19 | AC | 24 ms
25,196 KB |
testcase_20 | WA | - |
testcase_21 | AC | 26 ms
24,812 KB |
testcase_22 | AC | 25 ms
25,196 KB |
testcase_23 | AC | 25 ms
24,556 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 26 ms
24,940 KB |
testcase_29 | AC | 24 ms
24,812 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 29 ms
25,196 KB |
testcase_34 | WA | - |
testcase_35 | AC | 25 ms
24,940 KB |
testcase_36 | AC | 26 ms
25,196 KB |
testcase_37 | AC | 26 ms
25,196 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 26 ms
25,184 KB |
testcase_43 | AC | 26 ms
24,940 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | AC | 33 ms
25,196 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | AC | 35 ms
24,812 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | AC | 72 ms
25,196 KB |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | AC | 103 ms
24,940 KB |
testcase_98 | AC | 98 ms
25,052 KB |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | WA | - |
testcase_104 | WA | - |
testcase_105 | WA | - |
testcase_106 | AC | 104 ms
24,556 KB |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | WA | - |
testcase_117 | WA | - |
testcase_118 | WA | - |
testcase_119 | AC | 108 ms
24,556 KB |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | WA | - |
ソースコード
#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]++; } int lo = mp.begin()->first; 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 (d1 > d2) { ret[0] = make_pair(-lo2 + 1, -lo); // (十, 一) } else { ret[0] = make_pair(-lo + 1, -lo2); } for (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; } } else { int i = is[0], j = is[1]; pint p1 = ret[0] + pa; swap(pa.first, pa.second); pint p2 = ret[0] + pa; pint p = query(i, j); if (simulate(p1, p2) != p) swap(p1, p2); ret[i] = p1, ret[j] = p2; } } cout << "! "; for (auto x : ret) cout << x.first * N + x.second << ' '; cout << endl; }