QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#655695#9484. Colored Complete Graphucup-team3931#TL 0ms0kbC++141.5kb2024-10-19 09:13:052024-10-19 09:13:11

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 09:13:11]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-19 09:13:05]
  • 提交

answer

#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define R(i, x, y) for (int i = (x); i >= (y); i--)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
bool Mbe;

const int N = 1e5 + 5;
int n, to[N];
vector<int> o[2], g[N][2];

int q(int u, int v) {
	printf("! %d %d\n", u, v), fflush(stdout);
	char c[10]; scanf("%s", c);
	return c[0] == 'R' ? 0 : 1;
}

void add(int u, int v, int o) {
	g[u][o].eb(v), g[v][o].eb(u);
}

void solve() {
	cin >> n;
	F (i, 2, n) {
		int c = q(1, i);
		add(1, i, c);
		o[c].eb(i);
	}
	int cur = 0;
	if (o[cur].empty()) {
		printf("!\n");
		F (i, 2, n)
			printf("%d %d\n", 1, i);
		fflush(stdout);
		return;
	}
	while (!o[cur ^ 1].empty()) {
		int u = o[cur].back();
		while (!o[cur ^ 1].empty() && q(u, o[cur ^ 1].back()) == cur) 
			add(u, o[cur ^ 1].back(), cur), o[cur ^ 1].pop_back();
		if (!o[cur ^ 1].empty()) add(u, o[cur ^ 1].back(), cur ^ 1), o[cur].pop_back(), cur ^= 1;
	}
	printf("!\n");
	F (i, 1, n)
		for (int j : g[i][cur])
			if (i < j) printf("%d %d\n", i, j);
	fflush(stdout);
}

bool Med;
int main() {
	// FIO("");
	// ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	// cerr << (&Mbe - &Med) / 1048576.0 << " MB\n";
	int T = 1;
	// cin >> T;
	while (T--) solve();
	// cerr << (int)(1e3 * clock() / CLOCKS_PER_SEC) << " ms\n";
	return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:

! 1 2

result: