結果

問題 No.2085 Directed Complete Graph
ユーザー yimuhua2009
提出日時 2025-09-15 20:04:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 195,380 KB
実行使用メモリ 26,228 KB
平均クエリ数 661.00
最終ジャッジ日時 2025-09-15 20:04:34
合計ジャッジ時間 5,777 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#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[i]] = 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;
}
0