QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#200915#7510. Independent Setw4p3rTL 1ms3544kbC++201.9kb2023-10-05 00:42:202023-10-05 00:42:22

Judging History

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

  • [2023-10-05 00:42:22]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3544kb
  • [2023-10-05 00:42:20]
  • 提交

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 ;
	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
*/

詳細信息

Test #1:

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

input:

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

output:

? 4 1 2 3 4 
? 6 1 4 1 2 3 4 
? 4 1 2 3 4 
? 4 4 2 3 4 
? 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
Time Limit Exceeded

input:

4000
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 2 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 2 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 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 0 0...

output:

? 4000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result: