結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | kopricky |
提出日時 | 2020-12-03 14:46:13 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 5,118 bytes |
コンパイル時間 | 1,747 ms |
コンパイル使用メモリ | 179,860 KB |
実行使用メモリ | 25,580 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 08:44:04 |
合計ジャッジ時間 | 15,508 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
24,556 KB |
testcase_01 | AC | 24 ms
24,940 KB |
testcase_02 | AC | 22 ms
25,220 KB |
testcase_03 | AC | 24 ms
25,220 KB |
testcase_04 | AC | 25 ms
24,836 KB |
testcase_05 | AC | 22 ms
24,836 KB |
testcase_06 | AC | 23 ms
25,220 KB |
testcase_07 | AC | 22 ms
24,964 KB |
testcase_08 | AC | 24 ms
24,964 KB |
testcase_09 | AC | 24 ms
24,580 KB |
testcase_10 | AC | 24 ms
24,580 KB |
testcase_11 | AC | 24 ms
24,808 KB |
testcase_12 | AC | 23 ms
24,836 KB |
testcase_13 | AC | 23 ms
24,812 KB |
testcase_14 | AC | 23 ms
25,196 KB |
testcase_15 | AC | 22 ms
24,556 KB |
testcase_16 | AC | 24 ms
24,940 KB |
testcase_17 | AC | 25 ms
24,940 KB |
testcase_18 | AC | 24 ms
24,940 KB |
testcase_19 | AC | 24 ms
24,928 KB |
testcase_20 | AC | 24 ms
25,452 KB |
testcase_21 | AC | 23 ms
24,812 KB |
testcase_22 | AC | 23 ms
24,940 KB |
testcase_23 | AC | 24 ms
25,196 KB |
testcase_24 | AC | 24 ms
24,940 KB |
testcase_25 | AC | 24 ms
25,196 KB |
testcase_26 | AC | 24 ms
24,940 KB |
testcase_27 | AC | 23 ms
25,196 KB |
testcase_28 | AC | 23 ms
24,556 KB |
testcase_29 | AC | 23 ms
25,196 KB |
testcase_30 | AC | 23 ms
25,196 KB |
testcase_31 | AC | 23 ms
24,556 KB |
testcase_32 | AC | 23 ms
24,940 KB |
testcase_33 | AC | 25 ms
24,940 KB |
testcase_34 | AC | 25 ms
24,812 KB |
testcase_35 | AC | 24 ms
24,812 KB |
testcase_36 | AC | 24 ms
24,812 KB |
testcase_37 | AC | 25 ms
24,940 KB |
testcase_38 | AC | 24 ms
25,196 KB |
testcase_39 | AC | 25 ms
24,556 KB |
testcase_40 | AC | 25 ms
24,812 KB |
testcase_41 | AC | 25 ms
24,812 KB |
testcase_42 | AC | 25 ms
24,556 KB |
testcase_43 | AC | 24 ms
24,812 KB |
testcase_44 | AC | 26 ms
24,556 KB |
testcase_45 | AC | 26 ms
24,940 KB |
testcase_46 | AC | 27 ms
24,940 KB |
testcase_47 | AC | 27 ms
24,940 KB |
testcase_48 | AC | 29 ms
25,196 KB |
testcase_49 | AC | 29 ms
24,556 KB |
testcase_50 | AC | 29 ms
25,196 KB |
testcase_51 | AC | 31 ms
24,556 KB |
testcase_52 | AC | 33 ms
25,100 KB |
testcase_53 | AC | 36 ms
24,812 KB |
testcase_54 | AC | 33 ms
25,196 KB |
testcase_55 | AC | 36 ms
24,940 KB |
testcase_56 | AC | 37 ms
25,196 KB |
testcase_57 | AC | 40 ms
25,196 KB |
testcase_58 | AC | 41 ms
24,812 KB |
testcase_59 | AC | 39 ms
25,196 KB |
testcase_60 | AC | 47 ms
25,180 KB |
testcase_61 | AC | 50 ms
25,452 KB |
testcase_62 | AC | 50 ms
24,800 KB |
testcase_63 | AC | 53 ms
24,940 KB |
testcase_64 | AC | 51 ms
25,196 KB |
testcase_65 | AC | 56 ms
24,940 KB |
testcase_66 | AC | 61 ms
25,196 KB |
testcase_67 | AC | 62 ms
24,940 KB |
testcase_68 | AC | 60 ms
24,940 KB |
testcase_69 | AC | 65 ms
25,196 KB |
testcase_70 | AC | 66 ms
25,324 KB |
testcase_71 | AC | 69 ms
24,940 KB |
testcase_72 | AC | 69 ms
24,556 KB |
testcase_73 | AC | 67 ms
24,556 KB |
testcase_74 | AC | 78 ms
24,812 KB |
testcase_75 | AC | 75 ms
24,784 KB |
testcase_76 | AC | 86 ms
24,940 KB |
testcase_77 | AC | 91 ms
24,940 KB |
testcase_78 | AC | 96 ms
25,184 KB |
testcase_79 | AC | 104 ms
24,812 KB |
testcase_80 | AC | 108 ms
24,812 KB |
testcase_81 | AC | 88 ms
24,940 KB |
testcase_82 | AC | 114 ms
24,556 KB |
testcase_83 | AC | 115 ms
25,196 KB |
testcase_84 | AC | 125 ms
25,196 KB |
testcase_85 | AC | 131 ms
24,940 KB |
testcase_86 | AC | 106 ms
25,452 KB |
testcase_87 | AC | 112 ms
25,184 KB |
testcase_88 | AC | 140 ms
24,812 KB |
testcase_89 | AC | 116 ms
24,812 KB |
testcase_90 | AC | 101 ms
24,544 KB |
testcase_91 | AC | 112 ms
25,196 KB |
testcase_92 | AC | 102 ms
24,556 KB |
testcase_93 | AC | 121 ms
24,812 KB |
testcase_94 | AC | 103 ms
24,812 KB |
testcase_95 | AC | 108 ms
24,812 KB |
testcase_96 | AC | 99 ms
25,196 KB |
testcase_97 | AC | 100 ms
24,940 KB |
testcase_98 | AC | 95 ms
25,196 KB |
testcase_99 | AC | 113 ms
25,196 KB |
testcase_100 | AC | 113 ms
25,196 KB |
testcase_101 | AC | 122 ms
24,556 KB |
testcase_102 | AC | 100 ms
24,940 KB |
testcase_103 | AC | 108 ms
24,556 KB |
testcase_104 | AC | 106 ms
25,168 KB |
testcase_105 | AC | 107 ms
24,544 KB |
testcase_106 | AC | 97 ms
25,196 KB |
testcase_107 | AC | 109 ms
24,940 KB |
testcase_108 | AC | 101 ms
24,812 KB |
testcase_109 | AC | 122 ms
24,940 KB |
testcase_110 | AC | 100 ms
25,452 KB |
testcase_111 | AC | 101 ms
25,580 KB |
testcase_112 | AC | 93 ms
24,940 KB |
testcase_113 | AC | 128 ms
24,940 KB |
testcase_114 | AC | 128 ms
24,556 KB |
testcase_115 | AC | 108 ms
25,196 KB |
testcase_116 | AC | 132 ms
25,196 KB |
testcase_117 | AC | 110 ms
24,556 KB |
testcase_118 | AC | 121 ms
24,556 KB |
testcase_119 | AC | 107 ms
25,440 KB |
testcase_120 | AC | 99 ms
24,556 KB |
testcase_121 | AC | 118 ms
25,452 KB |
testcase_122 | AC | 114 ms
25,196 KB |
ソースコード
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(const auto& (a): (b)) #define all(v) (v).begin(),(v).end() #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<<endl #define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;} using namespace std; template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";} template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;} template<typename S,typename T,typename U> auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;} template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;} template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;} void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);} template<typename S,typename T,typename U> struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){} bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}}; template<typename S,typename T,typename U> auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";} typedef pair<int, int> P; typedef pair<ll,ll> pll; typedef TRI<int, int, int> tri; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<P> vp; typedef vector<string> vs; const int MAX_N = 100005; int main() { int n, u, v, w, x, s, t; cin >> n; vp res(n*n-n); int cnt1 = 0, cnt2 = 0, mx1 = 0, mx2 = 0, mem1 = 0, mem2 = 0; srep(i,1,n*n-n){ cout << "? 1 " << i + 1 << endl; cin >> u >> v; res[i] = {u, v}; if(v <= 0 && mx1 < abs(u) + abs(v)){ mx1 = abs(u) + abs(v), mem1 = i; } if(u >= 0 && mx2 < abs(u) + abs(v)){ mx2 = abs(u) + abs(v), mem2 = i; } if(u == 0) ++cnt1; else if(u > 0) ++cnt2; } assert(mem1 >= 0 && mem2 >= 0); if(mem1 == 0) res[0] = {n-1, n-1}; else if(mem2 == 0) res[0] = {1, 0}; else{ res[0] = {0, 0}; srep(i,1,n){ int j = cnt1 - (i - 1); if(j < 0 || j >= n) continue; if((i - 1) * j == cnt2 && (i - res[mem1].fi == n - 1 || i - res[mem1].se == n - 1)){ res[0].fi = i, res[0].se = j; break; } } assert(res[0].fi > 0); } auto in = [&](const int i, const int j){ return (i >= 1 && i < n && j >= 0 && j < n); }; map<P, bool> mp; if(res[0].fi == res[0].se){ srep(i,1,n*n-n){ u = res[0].fi - res[i].fi, v = res[0].se - res[i].se; w = res[0].fi - res[i].se, x = res[0].se - res[i].fi; if(in(u, v)){ if(res[i].fi != res[i].se && in(w, x)){ auto it = mp.find(res[i]); if(it == mp.end()){ cout << "? " << i + 1 << " " << mem2 + 1 << endl; cin >> s >> t; if(u == s + 1 || u == t + 1) mp[res[i]] = false, res[i] = {u, v}; else mp[res[i]] = true, res[i] = {w, x}; }else{ if(it->se) res[i] = {u, v}; else res[i] = {w, x}; } }else{ res[i] = {u, v}; } }else{ assert(in(w, x)); res[i] = {w, x}; } } }else{ srep(i,1,n*n-n){ u = res[0].fi - res[i].fi, v = res[0].se - res[i].se; w = res[0].fi - res[i].se, x = res[0].se - res[i].fi; if(in(u, v)){ if(res[i].fi != res[i].se && in(w, x)){ auto it = mp.find(res[i]); if(it == mp.end()){ cout << "? " << i + 1 << " " << mem1 + 1 << endl; cin >> s >> t; if(u == s + (n - 1) || u == t + (n - 1)) mp[res[i]] = false, res[i] = {u, v}; else mp[res[i]] = true, res[i] = {w, x}; }else{ if(it->se) res[i] = {u, v}; else res[i] = {w, x}; } }else{ res[i] = {u, v}; } }else{ assert(in(w, x)); res[i] = {w, x}; } } } cout << "!"; rep(i,n*n-n){ cout << " " << res[i].fi * n + res[i].se; } cout << endl; return 0; }