結果
| 問題 |
No.2124 Guess the Permutation
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2023-04-22 21:08:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 713 bytes |
| コンパイル時間 | 961 ms |
| コンパイル使用メモリ | 65,656 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 374.60 |
| 最終ジャッジ日時 | 2024-11-07 08:45:08 |
| 合計ジャッジ時間 | 2,622 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <set>
#include <string.h>
using namespace std;
int main() {
// your code goes here
int n;
long long int all=0;
set<long long int> ss;
cin>>n;
for(int i=1;i<=n;i++){
all+=i;
ss.insert(i);
}
long long int ans[1003],ds[1003];
memset(ans,0,sizeof(ans));
memset(ds,0,sizeof(ds));
long long int t;
for(int i=2;i<n;i++){
cout<<"? "<<i<<" "<<n<<endl;
cout<<flush;
cin>>t;
ds[i]=t;
ans[i-1]=all-t;
all-=ans[i-1];
ss.erase(ans[i-1]);
}
cout<<"? "<<n-2<<" "<<n-1<<endl;
cout<<flush;
cin>>t;
ans[n-1]=t-ans[n-2];
ss.erase(ans[n-1]);
ans[n]=(*(ss.begin()));
cout<<"!";
for(int i=1;i<=n;i++){
cout<<" "<<ans[i];
}
cout<<endl;
cout<<flush;
return 0;
}
horiesiniti