QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#496852#4218. Hidden GraphPZhengRE 0ms3596kbC++141.0kb2024-07-28 16:33:042024-07-28 16:33:05

Judging History

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

  • [2024-07-28 16:33:05]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3596kb
  • [2024-07-28 16:33:04]
  • 提交

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 q(vector<int>& vis, int x) {
	int cnt = 0;
	for(int i = 1; i <= x; i++) 
		cnt += (vis[i] == 0);
	cout << "? " << cnt << " ";
	for(int i = 1; i <= x; i++)
		if(!vis[i])
			cout << i << " ";
	cout << 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;
	for(int i = 1; i <= n; i++) {
		vector<int> vis(n + 1, 0);
		int now = q(vis, i);
		while(now != -1) {
			vis[now] = 1;
			ans.push_back({now, i});
			now = q(vis, i);
		}
	}
	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: 0ms
memory: 3596kb

input:

3
-1 -1
1 2
-1 -1
1 3
2 3
-1 -1

output:

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

result:

ok correct

Test #2:

score: -100
Runtime Error

input:

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

output:

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

result: