QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#573184#8239. Mysterious TreePanjyWA 1ms3512kbC++173.6kb2024-09-18 17:39:492024-09-18 17:39:49

Judging History

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

  • [2024-09-18 17:39:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3512kb
  • [2024-09-18 17:39:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;

const ll mod = 1000000007;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};

void solve()
{
    auto ask = [&](int a, int b)
    {
        cout << "? " << a << " " << b << endl;
        int op = 1;
        cin >> op;
        return op;
    };
    int n;
    cin >> n;
    vector<array<int, 2>> q;
    if (n & 1)
        if (ask(n - 1, n))
            q.push_back({n - 1, n});
    for (int i = 2; i <= n; i += 2)
        if (ask(i - 1, i))
            q.push_back({i - 1, i});
    if (q.size())
        return void(cout << "! 2" << endl);

    if (q[0][1] == n)
    {
        bool flag = ask(1, n);
        if (flag)
        {
            bool flag1 = ask(2, n);
            if (flag1)
                cout << "! 2" << endl;
            else
                cout << "! 1" << endl;
        }
        else
        {
            bool flag1 = ask(1, n - 1);
            if (!flag1)
                cout << "! 1" << endl;
            else
            {
                bool flag2 = ask(2, n - 1);
                if (!flag2)
                    cout << "! 1" << endl;
                else
                    cout << "! 2" << endl;
            }
        }
    }
    else
    {
        bool flag = ask(q[0][0], n);
        if (flag)
        {
            bool flag1 = ask(q[0][0], n - 1);
            if (flag1)
                cout << "! 2" << endl;
            else
                cout << "! 1" << endl;
        }
        else
        {
            bool flag1 = ask(q[0][1], n);
            if (!flag1)
                cout << "! 1" << endl;
            else
            {
                bool flag2 = ask(q[0][1], n - 1);
                if (!flag2)
                    cout << "! 1" << endl;
                else
                    cout << "! 2" << endl;
            }
        }
    }
}

int main()
{
    int T = 1;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

/*
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
x                                                                                      o
o       _/_/_/_/                                                              _/       x
x      _/                                                                              o
o     _/_/_/_/ _/  _/_/   _/_/   _/_/_/ _/_/   _/_/_/     _/_/    _/_/_/    _/ _/   _/ x
x    _/       _/_/     _/    _/ _/   _/   _/  _/    _/ _/    _/  _/    _/  _/   _/ _/  o
o   _/       _/       _/    _/ _/   _/   _/  _/    _/ _/    _/  _/    _/  _/    _/_/   x
x  _/       _/         _/_/   _/   _/   _/  _/_/_/     _/_/ _/ _/    _/  _/      _/    o
o                                          _/                           _/      _/     x
x                                         _/                        _/_/       _/      o
o                                                                                      x
xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3512kb

input:

2
4
1
1

output:

? 1 2
? 3 4
! 2

result:

wrong answer Wrong prediction (test case 1)