QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#622362 | #8939. Permutation | ucup-team1264 | WA | 1ms | 3700kb | C++20 | 1.0kb | 2024-10-08 21:08:55 | 2024-10-08 21:08:56 |
Judging History
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)