QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573044#8239. Mysterious TreePanjyWA 1ms3624kbC++172.9kb2024-09-18 17:10:062024-09-18 17:10:07

Judging History

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

  • [2024-09-18 17:10:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2024-09-18 17:10:06]
  • 提交

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() != 1)
        return void(cout << "! 1" << 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;
            }
        }
    }
}

int main()
{
    IOS 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
*/

詳細信息

Test #1:

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

input:

2
4
1
1

output:

? 1 2
? 1 2
? 2 2
! 2

result:

wrong answer u != v (test case 1)