結果
問題 | No.2577 Simple Permutation Guess |
ユーザー | tko919 |
提出日時 | 2023-12-05 01:03:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
QLE
|
実行時間 | - |
コード長 | 3,091 bytes |
コンパイル時間 | 2,120 ms |
コンパイル使用メモリ | 209,904 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 248.94 |
最終ジャッジ日時 | 2024-09-26 23:50:10 |
合計ジャッジ時間 | 21,725 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
24,940 KB |
testcase_01 | AC | 234 ms
24,556 KB |
testcase_02 | AC | 53 ms
24,940 KB |
testcase_03 | AC | 22 ms
24,940 KB |
testcase_04 | AC | 81 ms
24,812 KB |
testcase_05 | AC | 98 ms
25,196 KB |
testcase_06 | AC | 315 ms
24,940 KB |
testcase_07 | AC | 312 ms
24,812 KB |
testcase_08 | AC | 320 ms
24,812 KB |
testcase_09 | AC | 308 ms
24,928 KB |
testcase_10 | AC | 308 ms
24,940 KB |
testcase_11 | AC | 21 ms
24,940 KB |
testcase_12 | AC | 19 ms
25,196 KB |
testcase_13 | AC | 23 ms
24,812 KB |
testcase_14 | AC | 22 ms
24,940 KB |
testcase_15 | AC | 21 ms
25,196 KB |
testcase_16 | AC | 19 ms
25,184 KB |
testcase_17 | AC | 20 ms
24,940 KB |
testcase_18 | AC | 21 ms
24,812 KB |
testcase_19 | AC | 22 ms
24,812 KB |
testcase_20 | QLE | - |
testcase_21 | QLE | - |
testcase_22 | AC | 20 ms
24,836 KB |
testcase_23 | AC | 20 ms
25,220 KB |
testcase_24 | AC | 19 ms
24,580 KB |
testcase_25 | AC | 20 ms
24,580 KB |
testcase_26 | AC | 21 ms
24,836 KB |
testcase_27 | AC | 21 ms
24,836 KB |
testcase_28 | AC | 20 ms
24,580 KB |
testcase_29 | AC | 21 ms
24,836 KB |
testcase_30 | AC | 21 ms
24,964 KB |
testcase_31 | AC | 20 ms
24,940 KB |
testcase_32 | AC | 20 ms
24,940 KB |
testcase_33 | AC | 20 ms
24,940 KB |
testcase_34 | AC | 21 ms
24,940 KB |
testcase_35 | AC | 20 ms
24,812 KB |
testcase_36 | AC | 21 ms
24,556 KB |
testcase_37 | AC | 21 ms
24,964 KB |
testcase_38 | AC | 21 ms
24,964 KB |
testcase_39 | AC | 21 ms
24,836 KB |
testcase_40 | AC | 21 ms
24,452 KB |
testcase_41 | AC | 21 ms
24,964 KB |
testcase_42 | AC | 21 ms
24,836 KB |
testcase_43 | AC | 22 ms
24,836 KB |
testcase_44 | AC | 21 ms
24,836 KB |
testcase_45 | AC | 20 ms
24,964 KB |
testcase_46 | AC | 20 ms
25,220 KB |
testcase_47 | AC | 20 ms
24,580 KB |
testcase_48 | AC | 21 ms
24,964 KB |
testcase_49 | AC | 20 ms
24,580 KB |
testcase_50 | AC | 20 ms
24,964 KB |
testcase_51 | AC | 20 ms
24,964 KB |
testcase_52 | AC | 21 ms
25,192 KB |
testcase_53 | AC | 21 ms
24,568 KB |
testcase_54 | AC | 20 ms
24,964 KB |
testcase_55 | AC | 20 ms
24,836 KB |
testcase_56 | AC | 21 ms
24,964 KB |
testcase_57 | AC | 20 ms
25,160 KB |
testcase_58 | AC | 21 ms
24,836 KB |
testcase_59 | AC | 20 ms
25,204 KB |
testcase_60 | AC | 20 ms
24,964 KB |
testcase_61 | AC | 19 ms
25,220 KB |
testcase_62 | QLE | - |
testcase_63 | QLE | - |
testcase_64 | AC | 20 ms
24,964 KB |
testcase_65 | AC | 22 ms
24,836 KB |
testcase_66 | AC | 20 ms
24,964 KB |
testcase_67 | AC | 20 ms
24,836 KB |
testcase_68 | AC | 21 ms
24,836 KB |
testcase_69 | AC | 20 ms
24,964 KB |
testcase_70 | AC | 20 ms
24,836 KB |
testcase_71 | AC | 20 ms
24,836 KB |
testcase_72 | AC | 20 ms
25,136 KB |
testcase_73 | AC | 20 ms
24,812 KB |
testcase_74 | AC | 23 ms
24,812 KB |
testcase_75 | AC | 21 ms
24,556 KB |
testcase_76 | AC | 22 ms
24,812 KB |
testcase_77 | AC | 23 ms
24,812 KB |
testcase_78 | AC | 22 ms
24,812 KB |
testcase_79 | AC | 21 ms
25,148 KB |
testcase_80 | AC | 22 ms
25,196 KB |
testcase_81 | AC | 22 ms
24,556 KB |
testcase_82 | AC | 23 ms
24,556 KB |
testcase_83 | AC | 22 ms
25,196 KB |
testcase_84 | AC | 20 ms
24,812 KB |
testcase_85 | AC | 23 ms
24,940 KB |
testcase_86 | AC | 23 ms
24,556 KB |
testcase_87 | AC | 22 ms
24,556 KB |
testcase_88 | AC | 22 ms
24,940 KB |
testcase_89 | AC | 23 ms
24,940 KB |
testcase_90 | AC | 23 ms
24,556 KB |
testcase_91 | AC | 23 ms
25,196 KB |
testcase_92 | AC | 235 ms
24,812 KB |
testcase_93 | AC | 209 ms
24,556 KB |
testcase_94 | AC | 201 ms
25,196 KB |
testcase_95 | AC | 293 ms
24,812 KB |
testcase_96 | AC | 303 ms
24,556 KB |
testcase_97 | AC | 269 ms
25,196 KB |
testcase_98 | AC | 264 ms
24,812 KB |
testcase_99 | AC | 283 ms
24,556 KB |
testcase_100 | AC | 200 ms
24,556 KB |
testcase_101 | AC | 269 ms
24,940 KB |
evil_1_rnd_1.txt | AC | 746 ms
24,812 KB |
evil_1_rnd_2.txt | AC | 780 ms
25,196 KB |
evil_2_big_1.txt | AC | 1,057 ms
24,812 KB |
evil_2_big_2.txt | AC | 1,076 ms
24,812 KB |
evil_2_big_3.txt | AC | 1,061 ms
24,940 KB |
evil_3_sorted_1.txt | AC | 446 ms
24,952 KB |
evil_4_sorted_rev_1.txt | AC | 317 ms
24,580 KB |
evil_4_sorted_rev_2.txt | AC | 506 ms
24,836 KB |
evil_400_sorted.txt | AC | 916 ms
24,568 KB |
evil_400_sorted_rev.txt | AC | 944 ms
24,836 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 last=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(R==last and ask(R))answer(R); else answer(L); return 0; }