結果
問題 |
No.2124 Guess the Permutation
|
ユーザー |
![]() |
提出日時 | 2022-11-18 21:28:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 1,986 ms |
コンパイル使用メモリ | 194,272 KB |
最終ジャッジ日時 | 2025-02-08 21:26:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int sum = (1+N)*N/2; vector<int>ans(N); for(int i = 0; i < N-2; i++) { cout << "? " << i+2 << " " << N << endl; int a; cin >> a; ans[i] = sum-a; sum = a; } cout << "? " << 1 << " " << N-1 << endl; int a; cin >> a; ans[N-1] = (1+N)*N/2-a; ans[N-2] = sum-ans[N-1]; cout << "! "; for(int i = 0; i < N; i++) { cout << ans[i]; if(i+1 != N) { cout << " "; } } cout << endl; } /* 4 3 1 2 */