QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#766727#8056. Travel 2wangjunruiRE 0ms0kbC++141.1kb2024-11-20 18:24:102024-11-20 18:24:15

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2505;
typedef long long ll;
map<int, int> mp[N];
int a[N], b[N];
inline int get(int x)
{
	cout << "< " << x << endl;
	int p, q;
	cin >> p >> q;
	a[p] = q;
	return p;
}
vector<pair<int, int>> edges;
inline void dfs(int u, int _fa)
{
	while (b[u] < a[u])
	{
		int v = get(++b[u]);
		mp[u][v] = b[u];
		edges.emplace_back(u, v);
		if (edges.back().first > edges.back().second)
			swap(edges.back().first, edges.back().second);
		if (v == _fa)
			get(mp[v][u]);
		else
			dfs(v, u);
	}
	if (_fa)
		get(mp[u][_fa]);
}
inline void work()
{
	int p, q;
	cin >> p >> q;
	a[p] = q;
	dfs(p, 0);
	sort(edges.begin(), edges.end());
	edges.erase(unique(edges.begin(), edges.end()), edges.end());
	cout << '!';
	for (auto i : edges)
	{
		cout << ' ' << i.first << ' ' << i.second;
		b[i.first] = b[i.second] = 0;
		mp[i.first].clear(), mp[i.second].clear();
	}
	cout << endl;
	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

output:

< 1

result: