QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#200917#7510. Independent Setw4p3rRE 1ms3572kbC++201.9kb2023-10-05 00:45:262023-10-05 00:45:26

Judging History

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

  • [2023-10-05 00:45:26]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3572kb
  • [2023-10-05 00:45:26]
  • 提交

answer

#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i, a, b) for(int i = a; i <= b; i ++)
#define REP(i, a, b) for(int i = a; i >= b; i --)
#define pb push_back
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch = getchar();
	ll s = 0, w = 1;
	while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
	return s * w;
}
#define N 4010
int n, m;
int S = 0, cnt[N];
vector<pair<int, int>>ans;
vector<int> ask(vector<int>a)
{
	if (a.empty())return {};
	S += a.size(); assert(S <= 176000);
	cout << "? " << a.size() << ' ';
	for (int x : a)cout << x << ' '; cout << endl;
	vector<int>b;
	for (int x : a) {int t; cin >> t; b.push_back(t);}
	return b;
}
void calc(const vector<int>a, int l, int r, vector<int>b)
{
	if (b.empty())return ;
	vector<int>tmp;
	FOR(i, l, r)tmp.push_back(a[i]);
	for (int x : b)tmp.push_back(x);
	vector<int>G = ask(tmp); int m = b.size();
	vector<int>nb;
	if (l == r)
	{
		FOR(i, 0, m - 1)
		{
			int x = a[l], y = b[i];
			if (x <= y)while (G[i + 1] --)ans.push_back({x, y});
		}
		return ;
	}
	else
	{
		FOR(i, 0, m - 1)if (G[i + (r - l + 1)])nb.push_back(b[i]);
	}
	int mid = (l + r) >> 1;
	calc(a, l, mid, nb); calc(a, mid + 1, r, nb);
}
void sol(vector<int>c)
{
	if (c.empty())return ;
	random_shuffle(c.begin(), c.end());
	vector<int>tmp = ask(c);
	vector<int>X, Y;
	int m = c.size();
	FOR(i, 0, m - 1)if (!tmp[i])X.push_back(c[i]); else Y.push_back(c[i]);
	int k = X.size();
	calc(X, 0, k - 1, c);
	sol(Y);
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	vector<int>a(n);
	FOR(i, 0, n - 1)a[i] = i + 1;
	sol(a);
	cout << "!" << ' ';
	cout << ans.size() << ' ';
	for (auto [x, y] : ans)cout << x << ' ' << y << ' '; cout << endl;
	return 0;
}
/*
6
4 6 8 9 2 4
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
0 0 2 1
0 0 0 1 2 1
0 0 2 1
0 1 0 0
0 0
0 0 0 0

output:

? 4 1 4 2 3 
? 6 1 4 1 4 2 3 
? 4 1 4 2 3 
? 4 4 4 2 3 
? 2 2 3 
? 4 2 3 2 3 
! 4 1 2 1 2 1 3 4 4 

result:

ok Ok, Accepted!

Test #2:

score: -100
Runtime Error

input:

4000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0...

output:

? 4000 3187 1191 3594 3099 2401 469 707 3755 165 3913 3880 1030 362 3239 1736 3338 1417 1195 644 2974 1576 2756 421 2319 1186 1983 3141 1688 972 3019 3169 913 544 2256 3123 3672 3740 1270 3054 3447 67 673 3269 3760 3279 3137 107 799 3901 271 1269 1312 2287 3667 392 203 1387 1442 2472 3597 388 390 14...

result: