QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#326631#8239. Mysterious Treejames1BadCreeper#WA 1ms3584kbC++141.0kb2024-02-13 17:04:262024-02-13 17:04:27

Judging History

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

  • [2024-02-13 17:04:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3584kb
  • [2024-02-13 17:04:26]
  • 提交

answer

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

int n;  
int ask(int u, int v) {
    cout << "? " << u << " " << v << endl; 
    return cin >> u, u; 
}

void solve(void) {
    cin >> n; 
    int u = -1, v = -1; 
    for (int i = 1; i <= n; i += 2)
        if (ask(i, i + 1)) { u = i, v = i + 1; break; }
    if (ask(n - 1, n)) u = n - 1, v = n; 
    if (u == -1) return cout << "! 1" << endl, void(); // 一定不是菊花
    int t1 = -1, t2 = -1; 
    for (int i = 1; i <= n; ++i) if (i != u && i != v) { t1 = i; break; }
    for (int i = 1; i <= n; ++i) if (i != u && i != v && i != t1) { t2 = i; break; }
    int x = ask(u, t1), y = ask(v, t1); 
    if (!x && !y) return cout << "! 1" << endl, void(); 
    if (x && ask(x, t2)) return cout << "! 2" << endl, void(); 
    if (y && ask(y, t2)) return cout << "! 2" << endl, void(); 
    cout << "! 1" << endl; 
}

int main(void) {
    ios::sync_with_stdio(0); 
    int T; cin >> T; 
    while (T--) solve(); 
    return 0; 
}

详细

Test #1:

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

input:

2
4
1
1
0
0
4
0
1
1
1
0

output:

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

result:

wrong answer Too many queries , n = 4 , now_q 6 (test case 2)