ILE WA TLE求助,感觉没救了,qwq,悬关
查看原帖
ILE WA TLE求助,感觉没救了,qwq,悬关
637788
kimi0705楼主2023/12/18 23:25

T

#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int t;
int n, x;
vector<int> arr, now(N), Last(N), zero(N, 0);
int find() {
	int flag = -1;
	while (1) {
		now = zero;
		for (int& i : arr) {
			cin >> i;
			now[i]++;
		}
		if (now != Last) {
			break;
		}


		now = zero;
		
		cout << "- 0" << endl;
	}
	for (int i = 0; i < N; i++)
		if (now[i] == Last[i] + 1) {
			flag = i;
			break;
		}
	return flag;
}
int main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	cin >> t;
	while (t--) {
		cin >> n;
		now = zero;
		arr.resize(n);
		for (int& i : arr) {
			cin >> i;
			now[i]++;
		}
		Last = now;
		now = zero;
		
		cout << "- 0" << endl;
		int flag = find(), del_cnt = 0;

		for (int i = 0; i < n; i++)
			if (arr[i] != flag)
				del_cnt++;
		cout << "- " << del_cnt << ' ';
		for (int i = 0; i < n; i++)
			if (arr[i] != flag)
				cout << i + 1 << ' ';
		cout << endl;
		arr.resize(n - del_cnt);
		Last = zero;
		Last[flag] = n - del_cnt;
		for (int &i : arr) i = flag;
		flag = find();
		for (int i = 0; i < n; i++)
			if (arr[i] == flag) {
				cout << "! " << i + 1 << endl;
			}
	}
}
2023/12/18 23:25
加载中...