QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#766806#8056. Travel 2wangjunruiRE 0ms0kbC++141.3kb2024-11-20 18:42:112024-11-20 18:42:15

Judging History

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

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

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<pair<int, int>> edges;
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);
	for (int u = 1; u <= n; ++u)
		for (int v : g[u])
			if (u < v)
				edges.emplace_back(u, v);
	sort(edges.begin(), edges.end());
	edges.erase(unique(edges.begin(), edges.end()), edges.end());
	cout << '!';
	for (auto i : edges)
	{
		cout << ' ' << i.first << ' ' << i.second;
		mp[i.first][i.second] = mp[i.second][i.first] = 0;
	}
	cout << endl;
	for (int i = 1; i <= n; ++i)
	{
		b[i] = 0;
		vis[i] = 0;
		g[i].clear();
	}
	edges.clear();
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int T = 1;
	cin >> T;
	while (T--)
		work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

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: