結果
問題 | No.2577 Simple Permutation Guess |
ユーザー | tko919 |
提出日時 | 2023-12-05 00:59:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
QLE
|
実行時間 | - |
コード長 | 3,062 bytes |
コンパイル時間 | 2,831 ms |
コンパイル使用メモリ | 209,672 KB |
実行使用メモリ | 25,880 KB |
平均クエリ数 | 249.77 |
最終ジャッジ日時 | 2024-09-26 23:49:28 |
合計ジャッジ時間 | 22,783 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
25,196 KB |
testcase_01 | AC | 243 ms
24,556 KB |
testcase_02 | AC | 55 ms
24,556 KB |
testcase_03 | AC | 23 ms
25,196 KB |
testcase_04 | AC | 80 ms
24,428 KB |
testcase_05 | AC | 98 ms
24,940 KB |
testcase_06 | AC | 334 ms
25,196 KB |
testcase_07 | AC | 333 ms
24,812 KB |
testcase_08 | AC | 340 ms
24,812 KB |
testcase_09 | AC | 326 ms
25,196 KB |
testcase_10 | AC | 341 ms
24,812 KB |
testcase_11 | AC | 24 ms
25,184 KB |
testcase_12 | AC | 23 ms
24,940 KB |
testcase_13 | AC | 24 ms
24,812 KB |
testcase_14 | AC | 24 ms
25,168 KB |
testcase_15 | AC | 22 ms
24,428 KB |
testcase_16 | AC | 22 ms
24,556 KB |
testcase_17 | AC | 22 ms
24,940 KB |
testcase_18 | AC | 21 ms
25,196 KB |
testcase_19 | QLE | - |
testcase_20 | QLE | - |
testcase_21 | QLE | - |
testcase_22 | QLE | - |
testcase_23 | QLE | - |
testcase_24 | AC | 21 ms
24,824 KB |
testcase_25 | QLE | - |
testcase_26 | QLE | - |
testcase_27 | QLE | - |
testcase_28 | QLE | - |
testcase_29 | QLE | - |
testcase_30 | AC | 22 ms
24,836 KB |
testcase_31 | AC | 22 ms
24,556 KB |
testcase_32 | QLE | - |
testcase_33 | AC | 22 ms
24,428 KB |
testcase_34 | QLE | - |
testcase_35 | AC | 20 ms
25,148 KB |
testcase_36 | AC | 21 ms
24,812 KB |
testcase_37 | AC | 22 ms
25,076 KB |
testcase_38 | AC | 22 ms
25,220 KB |
testcase_39 | AC | 21 ms
24,964 KB |
testcase_40 | AC | 22 ms
25,220 KB |
testcase_41 | AC | 21 ms
24,836 KB |
testcase_42 | AC | 22 ms
25,220 KB |
testcase_43 | QLE | - |
testcase_44 | QLE | - |
testcase_45 | AC | 22 ms
24,836 KB |
testcase_46 | QLE | - |
testcase_47 | QLE | - |
testcase_48 | AC | 20 ms
24,836 KB |
testcase_49 | QLE | - |
testcase_50 | QLE | - |
testcase_51 | AC | 21 ms
24,964 KB |
testcase_52 | QLE | - |
testcase_53 | QLE | - |
testcase_54 | AC | 23 ms
24,836 KB |
testcase_55 | QLE | - |
testcase_56 | QLE | - |
testcase_57 | AC | 22 ms
24,836 KB |
testcase_58 | QLE | - |
testcase_59 | QLE | - |
testcase_60 | AC | 23 ms
25,220 KB |
testcase_61 | QLE | - |
testcase_62 | QLE | - |
testcase_63 | QLE | - |
testcase_64 | AC | 22 ms
24,452 KB |
testcase_65 | AC | 21 ms
24,580 KB |
testcase_66 | AC | 21 ms
24,836 KB |
testcase_67 | AC | 23 ms
25,184 KB |
testcase_68 | AC | 22 ms
24,964 KB |
testcase_69 | AC | 22 ms
24,452 KB |
testcase_70 | AC | 23 ms
24,836 KB |
testcase_71 | AC | 22 ms
25,076 KB |
testcase_72 | AC | 22 ms
24,964 KB |
testcase_73 | AC | 21 ms
24,812 KB |
testcase_74 | AC | 24 ms
25,196 KB |
testcase_75 | AC | 23 ms
24,428 KB |
testcase_76 | AC | 25 ms
24,428 KB |
testcase_77 | AC | 22 ms
24,812 KB |
testcase_78 | AC | 23 ms
24,812 KB |
testcase_79 | AC | 23 ms
25,196 KB |
testcase_80 | AC | 23 ms
24,940 KB |
testcase_81 | AC | 24 ms
24,556 KB |
testcase_82 | AC | 23 ms
24,812 KB |
testcase_83 | AC | 23 ms
25,196 KB |
testcase_84 | AC | 23 ms
25,196 KB |
testcase_85 | AC | 23 ms
24,812 KB |
testcase_86 | AC | 24 ms
24,940 KB |
testcase_87 | AC | 24 ms
24,428 KB |
testcase_88 | AC | 26 ms
24,812 KB |
testcase_89 | AC | 25 ms
24,556 KB |
testcase_90 | AC | 25 ms
24,812 KB |
testcase_91 | AC | 24 ms
24,940 KB |
testcase_92 | AC | 247 ms
25,580 KB |
testcase_93 | AC | 224 ms
24,812 KB |
testcase_94 | AC | 200 ms
24,812 KB |
testcase_95 | AC | 314 ms
24,940 KB |
testcase_96 | AC | 316 ms
24,812 KB |
testcase_97 | AC | 292 ms
25,196 KB |
testcase_98 | AC | 292 ms
24,940 KB |
testcase_99 | AC | 302 ms
24,812 KB |
testcase_100 | AC | 219 ms
24,428 KB |
testcase_101 | AC | 294 ms
25,196 KB |
evil_1_rnd_1.txt | AC | 797 ms
24,812 KB |
evil_1_rnd_2.txt | AC | 809 ms
25,452 KB |
evil_2_big_1.txt | AC | 1,108 ms
24,940 KB |
evil_2_big_2.txt | AC | 1,098 ms
24,940 KB |
evil_2_big_3.txt | AC | 1,070 ms
24,428 KB |
evil_3_sorted_1.txt | AC | 425 ms
24,824 KB |
evil_4_sorted_rev_1.txt | AC | 335 ms
24,964 KB |
evil_4_sorted_rev_2.txt | AC | 536 ms
24,836 KB |
evil_400_sorted.txt | AC | 907 ms
24,440 KB |
evil_400_sorted_rev.txt | AC | 1,049 ms
24,964 KB |
ソースコード
#line 1 "library/Template/template.hpp" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() #define UNIQUE(v) sort(ALL(v)),(v).erase(unique(ALL(v)),(v).end()) #define MIN(v) *min_element(ALL(v)) #define MAX(v) *max_element(ALL(v)) #define LB(v,x) lower_bound(ALL(v),(x))-(v).begin() #define UB(v,x) upper_bound(ALL(v),(x))-(v).begin() using ll=long long int; using ull=unsigned long long; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<typename T,typename U>T ceil(T x,U y){assert(y!=0); if(y<0)x=-x,y=-y; return (x>0?(x+y-1)/y:x/y);} template<typename T,typename U>T floor(T x,U y){assert(y!=0); if(y<0)x=-x,y=-y; return (x>0?x/y:(x-y+1)/y);} template<typename T>int popcnt(T x){return __builtin_popcountll(x);} template<typename T>int topbit(T x){return (x==0?-1:63-__builtin_clzll(x));} template<typename T>int lowbit(T x){return (x==0?-1:__builtin_ctzll(x));} #line 2 "sol.cpp" int ask(vector<int>& a){ cout<<"? "; rep(i,0,a.size())cout<<a[i]+1<<' '; cout<<endl; int B; cin>>B; return B; } void answer(vector<int>& a){ cout<<"! "; rep(i,0,a.size())cout<<a[i]+1<<' '; cout<<endl; } int main(){ int n; cin>>n; vector<int> L(n),R(n); iota(ALL(L),0); R=L; reverse(ALL(R)); auto convert=[&](vector<int>& a)->vector<int>{ vector<int> cnt(n),ret(n); rep(i,0,n){ int sum=0; rep(j,0,a[i])sum+=cnt[j]; ret[n-i-1]=a[i]-sum; cnt[a[i]]++; } return ret; }; auto inverse=[&](vector<int>& a)->vector<int>{ vector<int> ret(n),cnt(n); for(int i=n-1;i>=0;i--){ int sum=0; rep(j,0,n)if(cnt[j]==0){ sum++; if(sum==a[i]+1){ ret[n-1-i]=j; break; } } cnt[ret[n-1-i]]++; } return ret; }; for(;;){ auto nxt=L; next_permutation(ALL(nxt)); if(nxt==R)break; auto cL=convert(L); auto cR=convert(R); vector<int> cmid(n),odd(n),add(n); for(int i=n-1;i>=0;i--){ cmid[i]=(cL[i]+cR[i])/2; odd[i]=(cL[i]+cR[i])&1; } for(int i=n-1;i>0;i--)if(odd[i]){ if(i&1){ if(i>1)add[i-2]+=i*(i-1)/2; } else{ add[i-1]+=i/2; } } int up=0; rep(i,0,n){ cmid[i]+=add[i]+up; up=0; if(cmid[i]>i){ up+=cmid[i]/(i+1); cmid[i]%=(i+1); } } assert(up==0); auto mid=inverse(cmid); if(ask(mid))L=mid; else R=mid; } if(ask(R))answer(R); else answer(L); return 0; }