結果

問題 No.2124 Guess the Permutation
ユーザー RustiebeatsRustiebeats
提出日時 2022-11-18 21:28:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,306 bytes
コンパイル時間 1,675 ms
コンパイル使用メモリ 166,784 KB
実行使用メモリ 24,672 KB
平均クエリ数 172.90
最終ジャッジ日時 2023-10-20 06:16:20
合計ジャッジ時間 3,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _D321EBUG
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const long double pi = acos(-1.0);
const int INF = 1987654321;
// const int MOD = 1e9;
// 

int arr[1004];
int used[1004];

int main(){
#ifdef _DEBUG
    freopen ("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif  
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    for(int i = 2; i <= N; i++){
        cout << "? " << 1 << " " << i << endl;
        cout.flush();
        int x; cin >> x;
        // cin >> arr[i];
        if(i != 2){
            arr[i] = x - arr[i-1];
            used[arr[i]] = true;
        }
    }    
    cout << "? " << 1 << " " << 2 << endl;
    cout.flush();
    int sum12; cin >> sum12;
    arr[1] = 0;
    arr[2] = 0;
    for(int i = 1; i <= N; i++){
        if(!used[i]){
            arr[1] = i;
            used[i] = true;
            break;
        }
    }
    for(int i = 1; i <= N; i++){
        if(!used[i]){
            arr[2] = i;
            used[i] = true;
            break;
        }
    }
    
    cout << "! ";
    for(int i = 1; i <= N-1; i++) cout << arr[i] << " ";
    cout << arr[N];
    cout.flush();
    
    return 0;
}   
0