結果
問題 | No.850 企業コンテスト2位 |
ユーザー | QCFium |
提出日時 | 2019-07-12 14:26:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,009 bytes |
コンパイル時間 | 1,665 ms |
コンパイル使用メモリ | 174,048 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 200.11 |
最終ジャッジ日時 | 2024-07-16 17:48:23 |
合計ジャッジ時間 | 4,224 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); std::vector<int> x; for (int i = 0; i < n; i++) x.push_back(i); std::vector<std::pair<int, int> > log; while (x.size() > 1) { std::vector<int> next; for (int i = 0; i < x.size() / 2; i++) { log.push_back({x[2 * i], x[2 * i + 1]}); printf("? %d %d\n", log.back().first + 1, log.back().second + 1); fflush(stdout); int cur; scanf("%d", &cur); next.push_back(cur - 1); } if (x.size() % 2) next.push_back(x.back()); x.swap(next); } std::vector<int> y; for (auto &i : log) { if (i.first == x[0]) y.push_back(i.second); if (i.second == x[0]) y.push_back(i.first); } while (y.size() > 1) { std::vector<int> next; for (int i = 0; i < y.size() / 2; i++) { printf("? %d %d\n", y[2 * i] + 1, y[2 * i + 1] + 1); fflush(stdout); int cur; scanf("%d", &cur); next.push_back(cur - 1); } if (y.size() % 2) next.push_back(y.back()); y.swap(next); } printf("! %d\n", y[0] + 1); return 0; }