QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620076 | #8939. Permutation | zzpcd# | Compile Error | / | / | Python3 | 1.1kb | 2024-10-07 16:30:44 | 2024-10-07 16:30:49 |
Judging History
This is the latest submission verdict.
- [2024-10-07 16:30:49]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-07 16:30:44]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
int n;
const double k = 0.629;
int ask(int l, int r) {
if(l == r) return -1;
cout << "? " << l << ' ' << r << endl;
int x;
cin >> x;
return x;
}
void answer(int x) {
cout << "! " << x << endl;
return;
}
void solve(int l, int r, int sec = -1) {
if(l == r) {
answer(l);
return;
}
if(sec == -1) sec = ask(l, r);
if(l + 1 == r) {
answer(l == sec ? r : l);
return;
}
int mid = (r - l + 1) * k;
if(l + mid - 1 >= sec) {
mid = l + mid - 1;
int u = ask(l, mid);
if(u == sec) {
return solve(l, mid, sec);
} else return solve(mid + 1, r, -1);
} else {
mid = r - mid + 1;
int u = ask(mid, r);
if(u == sec) {
return solve(mid, r, sec);
} else return solve(l, mid - 1, -1);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--) {
int n;
cin >> n;
solve(1, n);
}
}
Details
File "answer.code", line 2 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax