QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622362#8939. Permutationucup-team1264WA 1ms3700kbC++201.0kb2024-10-08 21:08:552024-10-08 21:08:56

Judging History

This is the latest submission verdict.

  • [2024-10-08 21:08:56]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3700kb
  • [2024-10-08 21:08:55]
  • Submitted

answer

// https://www.youtube.com/watch?v=CrymicX875M
// Angel of mercy
// How did you move me
// Why am I on my feet again

#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 l = 1, r = n;
    int smx = query(1, n);
    double c = (sqrt(5) - 1) / 2;
    while (l < r) {
        if (smx == -1) smx = query(l, r);
        int len = c * (r - l + 1);
        int mid = l + len - 1;
        int p = query(l, mid);
        if (smx == p) {
            r = mid;
        } else {
            l = mid + 1;
            smx = -1;
        }
    }
}
#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: 0
Wrong Answer
time: 1ms
memory: 3700kb

input:

3
5
3
2
5

output:

? 1 5
? 1 3
? 4 5
? 4 4

result:

wrong answer Integer 4 violates the range [5, 5] (test case 1)