MnZn 求助交互题
查看原帖
MnZn 求助交互题
676634
Albert_Wei楼主2023/7/12 22:10
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline void solve() {
  int n;
  cin >> n;
  vector<int> a(n), cnt(10, 0), cntx(10, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cnt[a[i]]++;
  int col, num = 0;
  bool flag = false; 
  while (!flag) {
    cout << "- 0" << endl, cout.flush();
    for (int i = 1; i < 10; i++) cntx[i] = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cntx[a[i]]++;
    for (int i = 1; i < 10; i++)
      if (cnt[i] != cntx[i]) col = i, flag = true;
  }
  for (int i = 0; i < n; i++) num += (a[i] != col);
  cout << "- " << num << " ";
  for (int i = 0; i < n; i++)
    if (a[i] != col) cout << a[i] << " ";
  cout << endl, cout.flush(), n -= num;
  while (true) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] != col) {
      	cout << "! " << i + 1 << endl;
      	return ;
	  }
	}
	cout << "- 0" << endl, cout.flush();
  }
}

signed main() {
  int tt;
  cin >> tt;
  while (tt--) solve();
  return 0;
} 

2023/7/12 22:10
加载中...