QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#496984#4218. Hidden GraphPZhengWA 1ms3620kbC++141.4kb2024-07-28 17:42:312024-07-28 17:42:31

Judging History

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

  • [2024-07-28 17:42:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3620kb
  • [2024-07-28 17:42:31]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <random>
#include <chrono>

using namespace std;
using i64 = long long;
using u64 = unsigned long long;

mt19937_64 rng {std::chrono::steady_clock::now().time_since_epoch().count()};

int tot = 0;

int q(int x, vector<int>& vis, int co, vector<int>& col) {
	int cnt = 1;
	for(int i = 1; i <= x; i++) 
		cnt += col[i] == co && !vis[i];
	if(cnt == 1)
		return -1;
	cout << "? " << cnt << " ";
	for(int i = 1; i <= x; i++)
		if(col[i] == co && !vis[i])
			cout << i << " ";
	cout << x << endl;
	int r1, r2;
	cin >> r1 >> r2;
	if(r1 == -1)
		return r1;
	return r1 + r2 - x;
}

void solve() {
	int n;
	cin >> n;
	vector<array<int, 2>> ans;
	vector<int> col(n + 1, 0);
	for(int i = 1; i <= n; i++) {
		vector<int> pos;
		vector<int> vis(n + 1, 0);
		for(int j = 1; j <= tot; j++) {
			int now = q(i, vis, j, col);
			if(now == -1)
				pos.push_back(j);
			while(now != -1) {
				vis[now] = 1;
				ans.push_back({now, i});
				now = q(i, vis, j, col);
			}
		} 
		if(!pos.size())
			col[i] = ++tot;
		else {
			col[i] = rng() % i64(pos.size());
		}
	}
	cout << "! " << ans.size() << endl;
	for(auto x : ans)
		cout << x[0] << ' ' << x[1] << endl; 
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

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: -100
Wrong Answer
time: 1ms
memory: 3620kb

input:

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

output:

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

result:

wrong answer read 5 edges but expected 12 edges