QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#541519#8939. Permutationucup-team1264#WA 1ms3600kbC++201.2kb2024-08-31 19:49:362024-08-31 19:49:36

Judging History

This is the latest submission verdict.

  • [2024-08-31 19:49:36]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3600kb
  • [2024-08-31 19:49:36]
  • Submitted

answer

// https://www.youtube.com/watch?v=R0P_f0gXXqs
// I could feel your heartbeat
// I could feel somewhere you’re looking down
// ‘Cause it’s you who I’m loving
// And it’s you that I want in need

#ifndef ONLINE_JUDGE
#include "templates/debug.hpp"
#else
#define debug(...)
#endif

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;

#define int i64
int query(int l, int r) {
    cout << "? " << l << " " << r << endl;
    cin >> l; return l;
}
void solve() {
    int n; cin >> n;
    int i = query(1, n);
    int max_dis = max(i - 1, n - i);
    int dis = *ranges::partition_point(views::iota(1, max_dis), [&](int d) {
        return query(max<i64>(1, i - d), min(n, i + d)) != i;
    });
    int ans = -1;
    if (i - dis < 1) cout << "! " << i + dis << endl;
    else if (i + dis > n) cout << "! " << i - dis << endl;
    else {
        ans = (query(i - dis, i) == i) ? i - dis : i + dis;
        cout << "! " << ans << endl;
    }
}
#undef int

// Make bold hypotheses and verify carefully
int main() {
    // cin.tie(nullptr);
    // ios::sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    };
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3600kb

input:

3
5
3
3
2
6
6
3
6
4
3
3
2

output:

? 1 5
? 2 4
? 2 3
! 4
? 1 6
? 3 6
? 2 6
! 2
? 1 4
? 2 4
? 2 3
! 4

result:

ok Correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3600kb

input:

10000
10
2
2
2
3
10
10
10
7
10
10
5
5
5
4
4
10
4
4
4
4
4
10
10
6
3

output:

? 1 10
? 1 6
? 1 4
? 1 3
! 4
? 1 10
? 5 10
? 7 10
? 6 10
! 6
? 1 10
? 2 8
? 3 7
? 4 6
? 3 5
! 7
? 1 10
? 1 7
? 2 6
? 3 5
? 3 4
! 3
? 1 10
? 5 10
? 3 10
? 2 10

result:

wrong answer Too long queries, n = 10, now length 33 (test case 5)