Hướng dẫn giải của Mạng Xã Hội
Chỉ dùng lời giải này khi không có ý tưởng, và đừng copy-paste code từ lời giải này. Hãy tôn trọng người ra đề và người viết lời giải.
Nộp một lời giải chính thức trước khi tự giải là một hành động có thể bị ban.
Nộp một lời giải chính thức trước khi tự giải là một hành động có thể bị ban.
// Hello I'm Nekan // #include <bits/stdc++.h> #define Nekan "" #define fi first #define se second #define pb push_back #define zs(v) ((int)(v).size()) #define BIT(x, i) (((x) >> (i)) & 1) #define pii pair<int, int> typedef long double ld; typedef long long ll; const int N = 1e5 + 5; const long long mod = 1e9 + 7; /// 998244353 using namespace std; void xuly() { int n; cin >> n; int current = 1; auto ask = [&](int u, int v) { cout << "? " << u << " " << v << endl; string x; cin >> x; return (x == "True!"); }; for (int i = 2; i <= n; ++i) { if (!ask(current, i)) { current = i; } } bool is_source = true; for (int i = 1; i <= n; ++i) { if (i == current) continue; if (!(ask(current, i) && !ask(i, current))) { is_source = false; } } cout << "! " << (is_source ? to_string(current) : "FRIENDLY") << endl; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(0), cout.tie(0); if (fopen(Nekan ".inp", "r")) { freopen(Nekan ".inp", "r", stdin); freopen(Nekan ".out", "w", stdout); } int t; cin >> t; while(t--) xuly(); } //Surely nothing could go wrong.
Bình luận