QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#47369#4218. Hidden GraphCrysflyRE 6ms12316kbC++171.3kb2022-09-08 16:24:012022-09-08 16:24:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-08 16:24:04]
  • 评测
  • 测评结果:RE
  • 用时:6ms
  • 内存:12316kb
  • [2022-09-08 16:24:01]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

vector<pii>res;
int n,m;
vi o[maxn];
bool e[2005][2005];

bool chk(int x,int y){
	vi tmp=o[y];
	if(!tmp.size())return 1;
	while(tmp.size()){
		cout<<"? "<<tmp.size()+1<<" "<<x<<" ";
		for(auto t:tmp)cout<<t<<" ";cout<<endl;
		int u,v; cin>>u>>v;
		if(u==-1){
			if(tmp.size()==o[y].size())return 1;
			return 0;
		}
		tmp.erase(find(tmp.begin(),tmp.end(),u^v^x));
		for(auto p:tmp)assert(p!=(u^v^x));
		res.pb(mkp(u,v));
		e[u][v]=e[v][u]=1;
	}return 0;
}
int deg[maxn];
signed main()
{
	cin>>n;
	For(i,1,n){
		int id=0;
		For(j,1,m){
			bool ok=chk(i,j);
			if(!id&&ok)id=j;
		}
		if(!id)++m,id=m;
		o[id].pb(i);
	}
	For(i,1,n){
		For(j,1,n)deg[i]+=e[i][j];
		assert(m<=deg[i]+1);
	}
	cout<<"! "<<res.size()<<endl;
	for(auto t:res)cout<<t.fi<<" "<<t.se<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 9824kb

input:

3
1 2
1 3
2 3

output:

? 2 2 1 
? 2 3 1 
? 2 3 2 
! 3
1 2
1 3
2 3

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 12316kb

input:

10
1 2
1 3
-1 -1
1 4
-1 -1
-1 -1
2 5
4 5
-1 -1
-1 -1
2 6
-1 -1
-1 -1
3 7
-1 -1
-1 -1
4 8
3 8
-1 -1
-1 -1
3 9
-1 -1
-1 -1
4 10
3 10
-1 -1

output:

? 2 2 1 
? 2 3 1 
? 2 3 2 
? 2 4 1 
? 3 4 2 3 
? 2 5 1 
? 4 5 2 3 4 
? 3 5 3 4 
? 2 5 3 
? 3 6 1 5 
? 4 6 2 3 4 
? 3 6 3 4 
? 4 7 1 5 6 
? 4 7 2 3 4 
? 3 7 2 4 
? 5 8 1 5 6 7 
? 4 8 2 3 4 
? 3 8 2 3 
? 2 8 2 
? 6 9 1 5 6 7 8 
? 4 9 2 3 4 
? 3 9 2 4 
? 7 10 1 5 6 7 8 9 
? 4 10 2 3 4 
? 3 10 2 3 
? 2 ...

result:

ok correct

Test #3:

score: 0
Accepted
time: 6ms
memory: 8964kb

input:

5
2 1
3 1
3 2
4 1
4 2
-1 -1
5 1
5 2
-1 -1

output:

? 2 2 1 
? 2 3 1 
? 2 3 2 
? 2 4 1 
? 2 4 2 
? 2 4 3 
? 2 5 1 
? 2 5 2 
? 3 5 3 4 
! 7
2 1
3 1
3 2
4 1
4 2
5 1
5 2

result:

ok correct

Test #4:

score: 0
Accepted
time: 4ms
memory: 9784kb

input:

3
2 1
1 3
-1 -1

output:

? 2 2 1 
? 2 3 1 
? 2 3 2 
! 2
2 1
1 3

result:

ok correct

Test #5:

score: -100
Dangerous Syscalls

input:

6
1 2
3 1
3 2
-1 -1
4 2
3 4
4 5
-1 -1
2 5
3 5
-1 -1
-1 -1
3 6
-1 -1

output:

? 2 2 1 
? 2 3 1 
? 2 3 2 
? 2 4 1 
? 2 4 2 
? 2 4 3 
? 3 5 1 4 
? 2 5 1 
? 2 5 2 
? 2 5 3 
? 3 6 1 4 
? 2 6 2 
? 2 6 3 
? 2 6 5 

result: