結果
問題 |
No.2124 Guess the Permutation
|
ユーザー |
|
提出日時 | 2022-11-18 21:48:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 1,597 ms |
コンパイル使用メモリ | 197,608 KB |
最終ジャッジ日時 | 2025-02-08 21:35:40 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector<bool>u(N+1); vector<int>ans(N); cout<<"? 2 "<<N<<endl; int S; cin>>S; ans[0]=(N+1)*(N)/2-S; u[ans[0]]=true; for(int i=1;i<N-1;i++){ cout<<"? "<<i<<' '<<i+1<<endl; int s; cin>>s; ans[i]=s-ans[i-1]; u[ans[i]]=true; } for(int i=1;i<=N;i++){ if(!u[i])ans[N-1]=i; } cout<<'!'; for(int i:ans)cout<<' '<<i; cout<<endl; }