結果
問題 |
No.850 企業コンテスト2位
|
ユーザー |
![]() |
提出日時 | 2020-07-26 15:33:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 1,462 bytes |
コンパイル時間 | 2,963 ms |
コンパイル使用メモリ | 195,252 KB |
最終ジャッジ日時 | 2025-01-12 06:01:14 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int n; cin >> n; int a[n] = {}; int cnt = 0; int ite = 0; int x = -1; int y = -1; vector<int> G[1000]; while(cnt < n-1){ if(a[ite] == 0){ if(x == -1){ x = ite + 1; }else{ cnt++; y = ite + 1; cout << "? " << x << ' ' << y << endl; fflush(stdout); int z; cin >> z; if(z == x){ a[y-1] = 1; G[x].push_back(y); }else{ a[x-1] = 1; G[y].push_back(x); } x = -1; y = -1; } }else{ ; } ite++; ite %= n; } int win = -1; rep(i,n){ if(a[i]==0){ win = i+1; } } int two = G[win][0]; srep(i,1,G[win].size()){ cout << "? " << two << ' ' << G[win][i] << endl; fflush(stdout); int z; cin >> z; two = z; } cout << "! " << two << endl; return 0; }