結果
問題 | No.2124 Guess the Permutation |
ユーザー | Butterflv |
提出日時 | 2024-08-11 16:23:15 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 647 bytes |
コンパイル時間 | 2,826 ms |
コンパイル使用メモリ | 247,080 KB |
実行使用メモリ | 25,452 KB |
平均クエリ数 | 374.60 |
最終ジャッジ日時 | 2024-08-11 16:23:20 |
合計ジャッジ時間 | 4,296 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
// #define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; int N; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<<fixed<<setprecision(15); cin>>N; vector<int> S(N-1); vector<int> P(N, -1); cout<<"? "<<2<<' '<<N<<endl; cin>>S[1]; P[0]=N*(N+1)/2 - S[1]; cout<<"? "<<1<<' '<<N-1<<endl; cin>>S[0]; P[N-1]=N*(N+1)/2 - S[0]; for(int i=1;i<=N-3;i++){ cout<<"? "<<i+2<<' '<<N<<endl; cin>>S[i+1]; P[i]=S[i]-S[i+1]; } int Sum=0;for(int i=0;i<N;i++)if(i!=N-2)Sum+=P[i]; P[N-2]=N*(N+1)/2 - Sum; cout<<"! "; for(int i=0;i<N;i++)cout<<P[i]<<((i==N-1)?"":" "); cout<<endl; }