QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#341690#8239. Mysterious TreeOobugoOWA 0ms3712kbC++202.0kb2024-02-29 20:35:202024-02-29 20:35:20

Judging History

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

  • [2024-02-29 20:35:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2024-02-29 20:35:20]
  • 提交

answer

#include <bits/stdc++.h>

#define OobugoO_IOS std::ios::sync_with_stdio(false), std::cin.tie(nullptr)

typedef long long ll;

void solve() {
    int n;
    std::cin >> n;
    int num = 0;
    int p;
    for (int i = 1; i < n; i += 2) {
        std::cout << "? " << i << " " << i + 1 << "\n";
        int f;
        std::cin >> f;
        if (f) {
            num ++;
            p = i;
        }
    }
    if ((n & 1) && num == 0) {
        int f1, f2, f3;
        std::cout << "? " << n << " " << 1 << "\n";
        std::cin >> f1;
        std::cout << "? " << n << " " << 2 << "\n";
        std::cin >> f2;
        std::cout << "? " << n << " " << 3 << "\n";
        std::cin >> f3;
        if (f1 && f2 && f3) {
            std::cout << "! " << 1 << "\n";
        } else {
            std::cout << "! " << 0 << "\n";
        }
    } else if (num == 0 || num >= 2) {
        std::cout << "! " << 1 << "\n";
    } else {
        int f1;
        std::cout << "? " << p << " " << ((p + 1) % n) + 1 << "\n";
        std::cin >> f1;
        if (f1) {
            int f2;
            std::cout << "? " << p << " " << ((p + 2) % n) + 1 << "\n";
            std::cin >> f2;
            if (f2) {
                std::cout << "! " << 1 << "\n";
            } else {
                std::cout << "! " << 0 << "\n";
            }
        } else {
            int f2, f3;
            std::cout << "? " << p + 1 << " " << ((p + 1) % n) + 1 << "\n";
            std::cin >> f2;
            std::cout << "? " << p + 1 << " " << ((p + 2) % n) + 1 << "\n";
            std::cin >> f3;
            if (f2 && f3) {
                std::cout << "! " << 1 << "\n";
            } else {
                std::cout << "! " << 0 << "\n";
            }
        }
    }
}
int main() {

#ifdef Onlion_Judge
    freopen("IO/input.in", "r", stdin);
    freopen("IO/output.out", "w", stdout);
#endif

    // OobugoO_IOS;
    int t = 1;
    std::cin >> t;
    while(t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3712kb

input:

2
4
1
1
4
0
1
1
1

output:

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

result:

wrong answer Wrong prediction (test case 2)