QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#462780#1464. Interactive AlgorithmItsGuitarRE 0ms0kbC++141.4kb2024-07-04 04:00:002024-07-04 04:00:01

Judging History

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

  • [2024-07-04 04:00:01]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-04 04:00:00]
  • 提交

answer

#include<bits/stdc++.h>
#define TC while(t--)
#define DEBUG(x) cout<<"Debug "<<#x<<':'<<x<<endl;
#define EL "\n"
#define ll long long
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define st first
#define nd second
#define pb push_back
using namespace std;
void fast(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}
void solve(){
	int n;
	cin>>n;
	vector<int> graph[n+1];
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			cout<<"? "<<i<<" "<<j<<" ";
			for(int k=1;k<=n-2;k++){
				cout<<696969+k<<" ";
			}
			cout<<EL<<flush;
			int x;
			cin>>x;
			if(x==1){
				graph[i].pb(j);
				graph[j].pb(i);
			}
		}
	}
	int start;
	for(int i=1;i<=n;i++){
		if(sz(graph[i])==1){
			start=i;
			break;
		}
	}
	vector<int> ans;
	queue<int> q;
	vector<bool> visited(n+1,false);
	visited[start]=true;
	q.push(start);
	while(!q.empty()){
		int u=q.front();
		ans.pb(u);
		q.pop();
		for(auto v:graph[u]){
			if(!visited[v]){
				visited[v]=true;
				q.push(v);
			}
		}
	}
	cout<<"? ";
	for(auto it:ans) cout<<it<<" ";
	cout<<EL<<flush;
	int x;
	cin>>x;
	if(x==n-1){
		cout<<"! ";
		for(auto it:ans) cout<<it<<" ";
		cout<<flush;
	}
	else{
		reverse(ans.begin(),ans.end());
		cout<<"! ";
		for(auto it:ans) cout<<it<<" ";
		cout<<flush;
	}
}
int main(){
	fast();
	solve();
	/*int t;
	cin>>t;
	TC{
		solve();
	}*/
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

5

output:

? 1 2 696970 696971 696972 

result: