QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637980#8239. Mysterious TreeMoemi_WA 1ms3608kbC++201.8kb2024-10-13 14:32:292024-10-13 14:32:30

Judging History

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

  • [2024-10-13 14:32:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-10-13 14:32:29]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <numeric>

#define sc_int(x) scanf("%d", &x)

#define x first
#define y second
#define pb push_back

using namespace std;

const int N = 510, M = 2e5 + 10, MOD = 1e9 + 7;
const int inf = 1e9;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef pair<char, int> PCI;
typedef pair<string, string> PSS;

int n, m;

int query(int i, int j)
{
    int res;
    cout << "? " << i << " " << j << endl;
    cin >> res;
    return res;
}

void solve() 
{
    cin >> n;
    bool flag = 0;
    map<PII, int> mp;
    for(int i = 1; i + 1 <= n; i += 2)
    {
        mp[{i, i + 1}] = query(i, i + 1);
    }
    if(n & 1) mp[{1, n}] = query(1, n);
    int i = -1, j = -1;
    for(auto [x, y] : mp)
    {
        if(y) 
        {
            i = x.x, j = x.y;
            break;
        }
    }
    if(i == -1 && j == -1)
    {
        cout << "! " << 1 << endl;
        return;
    }
    for(int t = 1; t <= n; t ++)
    {
        if(t != i && t != j)
        {
            if(query(t, i) || query(t, j))
            {
                cout << "! " << 2 << endl;
            }
            else 
            {
                cout << "! " << 1 << endl;
            }
            break;
        }
    }
}

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    
    int T = 1;
    cin >> T;
    while(T --)
    {
        solve();
    }
}

详细

Test #1:

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

input:

2
4
1
1
0
1

output:

? 1 2
? 3 4
? 3 1
? 3 2
! 2

result:

wrong answer Wrong prediction (test case 1)