总是 WA on 15,自己没有看出来错误。
代码:
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
int n, k, d(1), u;
vector<int> vec;
bool ask(int x, int y, int c){ // c 是否在 (x,y) 上
cout << "? " << x << ' ' << c << ' ' << y << endl;
string s;
cin >> s;
return s == "Yes";
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for (int s(1); s<n; ++d) s += s*k;
for (int i(1); i<=30; ++i){
int x(rnd()%n+1), y(rnd()%n+1);
while (y == x) y = rnd()%n+1;
vec.clear();
for (int j(1); j<=n; ++j){
if (j != x && j != y && ask(x, y, j)) vec.push_back(j);
}
if (vec.size() == (d<<1)-3){
u = x;
break;
}
}
for (auto i: vec){
int cnt(0);
for (auto j: vec){
if (i == j) continue;
cnt += ask(u, i, j);
}
if (cnt == d-2){
cout << "! " << i << endl;
return 0;
}
}
return 0;
}