結果
問題 |
No.2085 Directed Complete Graph
|
ユーザー |
|
提出日時 | 2025-09-15 20:09:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 675 bytes |
コンパイル時間 | 1,829 ms |
コンパイル使用メモリ | 195,384 KB |
実行使用メモリ | 26,212 KB |
平均クエリ数 | 1032.41 |
最終ジャッジ日時 | 2025-09-15 20:09:11 |
合計ジャッジ時間 | 4,792 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 2 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct node { int s, t; }; int n, pre[505], nxt[505]; bool query(int x, int y) { cout << "? " << x << ' ' << y << endl, cin >> x; return x; } node f(int l, int r) { if(l == r) return {l, l}; int mid = l + r >> 1; auto x = f(l, mid), y = f(mid + 1, r); for(int i = x.t, j = y.t; i && j;) if(i && (!j || query(i, j))) nxt[i] = j, j = pre[j], pre[nxt[i]] = i; else nxt[j] = i, i = pre[i], pre[nxt[j]] = j; return {pre[y.s] ? x.s : y.s, nxt[y.t] ? x.t : y.t}; } int main() { cin >> n; auto res = f(1, n); cout << '!' << endl << n - 1 << endl; for(int i = res.s; i; i = nxt[i]) cout << i << ' '; return 0; }