QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#300468#7510. Independent Setdefyers#WA 5ms3824kbC++172.3kb2024-01-08 12:15:062024-01-08 12:15:06

Judging History

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

  • [2024-01-08 12:15:06]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3824kb
  • [2024-01-08 12:15:06]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using LL = long long;
using pii = pair<int, int>;

int n;
vector<int> v;
vector<vector<int>> IS;
vector<int> edge[4005];

vector<int> ask(vector<int> v) {
	cout << "?";
	for (auto i : v) {
		cout << " " << i;
	}
	cout << "\n";
	cout.flush();
	vector<int> ans;
	for (int i = 0; i < v.size(); i++) {
		int tmp;
		cin >> tmp;
		ans.push_back(tmp);
	}
	return ans;
}

void f(vector<int> s1, vector<int> s2) {
	if (!s2.size()) return;
	vector<int> tmp;
	for (auto i : s2) {
		tmp.push_back(i);
	}
	for (auto i : s1) {
		tmp.push_back(i);
	}
	auto ans = ask(tmp);
	if (s2.size() == 1) {
		for (int i = 0; i < s1.size(); i++) {
			int num = ans[i + 1];
			for (int j = 1; j <= num; j++) {
				edge[s1[i]].push_back(s2[0]);
			}
		}
		return;
	}
	int p = 0;
	vector<int> nonzero;
	for (int i = s2.size(); i < s2.size() + s1.size(); i++) {
		int cnt = ans[i];
		int id = s1[p];
		if (cnt != 0) nonzero.push_back(id);
		p++;
	}
	vector<int> h1, h2;
	for (int i = 0; i < s2.size(); i++) {
		if (i < s2.size() / 2) h1.push_back(s2[i]);
		else h2.push_back(s2[i]);
	}
	f(nonzero, h1);
	f(nonzero, h2);
	return;
}

void solve(int TC) {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		v.push_back(i);
	}
	while (v.size() > 1) {
		auto ans = ask(v);
		vector<int> v2, s;
		for (int i = 0; i < v.size(); i++) {
			if (ans[i] == 0) s.push_back(v[i]);
			else v2.push_back(v[i]);
		}
		v = v2;
		IS.push_back(s);
	}
	if (v.size() == 1) {
		IS.push_back(v);
		v.clear();
	}
	for (int i = 0; i < IS.size(); i++) {
		for (int j = i + 1; j < IS.size(); j++) {
			f(IS[i], IS[j]);
		}
	}
	for (int i = 1; i <= n; i++) {
		vector<int> tmp;
		tmp.push_back(i);
		tmp.push_back(i);
		auto ans = ask(tmp);
		int num = ans[1];
		for (int j = 1; j <= num; j++) {
			edge[i].push_back(i);
		}
	}
	int total = 0;
	for (int i = 1; i <= n; i++) {
		total += edge[i].size();
	}
	cout << "! " << total;
	for (int i = 1; i <= n; i++) {
		for (auto j : edge[i]) {
			cout << " " << i << " " << j;
		}
	}
	cout << "\n";
	cout.flush();
	return;
}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++) {
		solve(i);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 3824kb

input:

4
0

output:

? 1 2 3 4

result:

wrong answer Bad request