QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#766828#8056. Travel 2wangjunruiRE 0ms0kbC++141007b2024-11-20 18:46:282024-11-20 18:46:28

Judging History

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

  • [2024-11-20 18:46:28]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-20 18:46:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2505;
typedef long long ll;
int a[N], b[N];
int n;
inline int get(int x)
{
	cout << "> " << x << endl;
	int p, q;
	cin >> p >> q;
	a[p] = q;
	n = max(n, p);
	return p;
}
vector<int> g[N];
int mp[N][N];
bool vis[N];
inline void dfs(int u)
{
	if (b[u] < a[u])
	{
		int v = get(++b[u]);
		mp[u][v] = b[u];
		g[u].push_back(v);
		dfs(v);
		return;
	}
	vis[u] = true;
	for (int v : g[u])
	{
		if (!vis[v])
		{
			get(mp[u][v]);
			dfs(v);
			get(mp[v][u]);
		}
	}
}
inline void work()
{
	int p, q;
	cin >> p >> q;
	n = p;
	a[p] = q;
	dfs(p);
	cout << '!';
	for (int u = 1; u <= n; ++u)
		for (int v : g[u])
			if (u < v)
				cout << ' ' << u << ' ' << v;
	cout << endl;
	for (int i = 1; i <= n; ++i)
	{
		b[i] = 0;
		vis[i] = 0;
		g[i].clear();
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int T = 1;
	cin >> T;
	while (T--)
		work();
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

2
1 1
2 1
1 1
2 1
1 1
Correct
1 3
2 2

output:

> 1
> 1
> 1
> 1
! 1 2
> 1

result: