QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#496957#4218. Hidden GraphPZhengRE 0ms0kbC++141.3kb2024-07-28 17:15:182024-07-28 17:15:18

Judging History

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

  • [2024-07-28 17:15:18]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-28 17:15:18]
  • 提交

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> vis(n + 1, 0);
		for(int j = 1; j <= tot; j++) {
			int now = q(i, vis, j, col);
			if(now == -1)
				col[i] = j;
			while(now != -1) {
				vis[now] = 1;
				cout << now << endl;
				ans.push_back({now, i});
				now = q(i, vis, j, col);
			}
		} 
		if(!col[i])
			col[i] = ++tot;
	}
	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();
	}
}

详细

Test #1:

score: 0
Runtime Error

input:

3
1 2

output:

? 2 1 2
1
? 2 1 3

result: