QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#799119#8056. Travel 2123adadTL 0ms0kbC++23945b2024-12-04 22:25:532024-12-04 22:25:54

Judging History

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

  • [2024-12-04 22:25:54]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-12-04 22:25:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2505;
int d[N],vis[N],road[N][N];
vector<int> e[N];
void dfs(int u){
	int now=(int)e[u].size()-1;
	if(now<d[u]){
		now++;int x;
		cout<<"> "<<now<<endl;
		cin>>x;cin>>d[x];
		e[u].push_back(x);
		road[u][x]=now;
		dfs(x);
		return;
	}
	vis[u]=1;
	//cerr<<"u: "<<u<<"\n";
	for(int i=1;i<=now;i++){
		if(!vis[i]){
			int v=e[u][i];
			//cerr<<"v :"<<v<<"\n";
			int x;
			cout<<"> "<<i<<endl;
			cin>>x>>d[x];
			dfs(v);
			cout<<"> "<<road[v][u]<<endl;
			cin>>x>>d[x];
		}
	}
}
void solve(){
	for(int i=1;i<N-1;i++){
		vis[i]=0;
		e[i].clear();
		e[i].push_back(0);
	}
	int u;
	cin>>u;
	cin>>d[u];
	dfs(u);
	cout<<"! ";
	for(int i=1;i<N;i++){
		for(auto v:e[i]){
			if(i<v){
				cout<<i<<" "<<v<<" ";
			}
		}
	}
	cout<<endl;
	string s;cin>>s;
}
int main(){
	
	int _=1;cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

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

output:

> 1
> 1
! 1 2 
> 1
> 1
> 2
> 1
> 3
> 1
> 2
> 1
! 1 2 1 3 1 4 

result: