結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-07-05 22:30:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 912 bytes |
| コンパイル時間 | 1,995 ms |
| コンパイル使用メモリ | 176,388 KB |
| 実行使用メモリ | 25,832 KB |
| 平均クエリ数 | 200.11 |
| 最終ジャッジ日時 | 2024-07-16 17:23:38 |
| 合計ジャッジ時間 | 11,993 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
int n; cin >> n;
auto fn = [&](V<> id) -> VV<> {
VV<> v{id};
while (id.size() >= 2) {
int m = id.size();
V<> nid;
for (int i = 0; i < m; i += 2) {
if (i + 1 < m) {
cout << "? " << id[i] << ' ' << id[i + 1] << endl;
int x; cin >> x;
nid.push_back(x);
} else nid.push_back(id[i]);
}
swap(id, nid);
v.push_back(id);
}
return v;
};
V<> id(n);
iota(begin(id), end(id), 1);
auto v = fn(id);
int x = v.back().back();
V<>().swap(id);
for (const auto& e : v) {
int m = e.size();
for (int i = 0; i < m; ++i) if (e[i] == x) {
if ((i ^ 1) < m) id.push_back(e[i ^ 1]);
}
}
cout << fn(id).back().back() << '\n';
}
risujiroh