QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#98693#4218. Hidden Graph_yjhWA 4ms3576kbC++141.5kb2023-04-19 20:36:232023-04-19 20:36:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-19 20:36:26]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3576kb
  • [2023-04-19 20:36:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int n,mx,m,col[2005];
bool del[2005],vis[2005];
vector <int> nt[2005];
vector <int> v[2005];
int main() {
	cin>>n;
	nt[1].push_back(1);
	mx=1;
	for(int nw=2;nw<=n;nw++) {
		for(int i=1;i<=mx;i++) {
			if(!nt[i].size()) continue;
			int sz=nt[i].size();
			while(sz) {
				cout<<"? "<<sz+1<<' ';
				for(int k:nt[i]) {
					if(!del[k]) cout<<k<<' ';
				}
				cout<<nw<<endl;
				int x,y;
				cin>>x>>y;
				if(x==-1||y==-1) break;
				if(x==nw) swap(x,y);
				v[y].push_back(x);
				v[x].push_back(y);
				m++;
				del[x]=true;
				sz--;
			}
			nt[i].clear();
		}
		mx=n+1;
		for(int i=1;i<=nw;i++) {
			del[i]=false;
			col[i]=0;
//			cout<<i<<' '<<v[i].size()<<'\n';
			mx=min(mx,int(v[i].size())+1);
		}
//		cout<<mx<<'\n';
//		if(n==2000) assert(mx<=3);
		for(int i=1;i<=nw;i++) {
//			cout<<i<<' '<<col[i]<<'\n';
			if(!col[i]) {
				for(int j:v[i]) {
					if(col[j]) vis[col[j]]=true;
				}
				for(int j=1;j<=mx;j++) {
					if(!vis[j]) {
						col[i]=j;
						nt[j].push_back(i);
//						cout<<i<<' '<<col[i]<<'\n';
						break;
					}
				}
				for(int j:v[i]) {
					if(col[j]) vis[col[j]]=false;
				}
			}
		}
		if(n==2000) {
			for(int i=1;i<=n;i++) {
				for(int to:v[i]) {
					assert(col[i]!=col[to]);
				}
			}
		}
	}
	cout<<'!'<<' '<<m<<'\n';
	for(int i=1;i<=n;i++) {
		for(int j:v[i]) {
			if(j<i) continue;
			cout<<i<<' '<<j<<'\n';
		}
	}
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3432kb

input:

3
1 2
1 3
2 3

output:

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

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3576kb

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 1 2
? 2 1 3
? 2 2 3
? 2 1 4
? 3 2 3 4
? 2 1 5
? 4 2 3 4 5
? 3 3 4 5
? 2 3 5
? 3 1 5 6
? 4 2 3 4 6
? 3 3 4 6
? 4 1 5 6 7
? 4 2 3 4 7
? 3 2 4 7
? 5 1 5 6 7 8
? 4 2 3 4 8
? 3 2 3 8
? 2 2 8
? 6 1 5 6 7 8 9
? 4 2 3 4 9
? 3 2 4 9
? 7 1 5 6 7 8 9 10
? 4 2 3 4 10
? 3 2 3 10
? 2 2 10
! 12
1 2
1 3
1 4
2 5...

result:

ok correct

Test #3:

score: 0
Accepted
time: 3ms
memory: 3480kb

input:

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

output:

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

result:

ok correct

Test #4:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

3
2 1
1 3
-1 -1

output:

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

result:

ok correct

Test #5:

score: 0
Accepted
time: 3ms
memory: 3516kb

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

output:

? 2 1 2
? 2 1 3
? 2 2 3
? 2 1 4
? 2 2 4
? 2 3 4
? 3 1 4 5
? 2 1 5
? 2 2 5
? 2 3 5
? 3 1 4 6
? 2 2 6
? 2 3 6
! 9
1 2
1 3
2 3
2 4
2 5
3 4
3 5
3 6
4 5

result:

ok correct

Test #6:

score: -100
Wrong Answer
time: 4ms
memory: 3576kb

input:

27
-1 -1
3 1
3 2
-1 -1
-1 -1
1 5
2 5
-1 -1
6 1
-1 -1
-1 -1
1 8
-1 -1
1 9
-1 -1
-1 -1
4 11
1 11
-1 -1
-1 -1
10 13
-1 -1
14 1
14 12
-1 -1
10 15
-1 -1
10 16
-1 -1
-1 -1
12 18
17 18
-1 -1
1 19
2 19
-1 -1
-1 -1
21 1
21 2
21 17
-1 -1
1 22
7 22
22 20
-1 -1
-1 -1
6 13
5 11
21 18
3 15
19 11
8 13
22 16
16 18
...

output:

? 2 1 2
? 3 1 2 3
? 2 2 3
? 3 1 2 4
? 2 3 4
? 4 1 2 4 5
? 3 2 4 5
? 2 4 5
? 4 1 2 4 6
? 3 2 4 6
? 4 1 2 4 7
? 5 1 2 4 7 8
? 4 2 4 7 8
? 5 1 2 4 7 9
? 4 2 4 7 9
? 5 1 2 4 7 10
? 6 1 2 4 7 10 11
? 5 1 2 7 10 11
? 4 2 7 10 11
? 6 1 2 4 7 10 12
? 7 1 2 4 7 10 12 13
? 6 1 2 4 7 12 13
? 7 1 2 4 7 10 12 14...

result:

wrong answer read 39 edges but expected 88 edges