QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#858239 | #8939. Permutation | littleandy | Compile Error | / | / | C++14 | 815b | 2025-01-16 15:15:57 | 2025-01-16 15:16:05 |
Judging History
This is the latest submission verdict.
- [2025-01-16 15:16:05]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-01-16 15:15:57]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
const double P = (sqrt(5) - 1.0) / 2.0;
int ask(int l, int r) {
if (l == r) return 0;
printf("? %d %d\n", l, r);
int res; scanf("%d", &res);
return res;
}
void solve(int l, int r, int res) {
if (l == r) {printf("! %d\n", x); return;}
int mid1 = floor(double(l * (1.0 - P) + r * P));
int mid2 = floor(double(l * P + r * (1.0 - P)));
if (res <= mid2) {
int Res = ask(l, mid1);
if (res == Res) solve(l, mid1, Res);
else solve(mid1 + 1, r, ask(mid1 + 1, r));
} else {
int Res = ask(mid2 + 1, r);
if (res == Res) solve(mid2 + 1, r, Res);
else solve(l, mid2, ask(l, mid2));
}
}
void work() {
int n;
scanf("%d", &n);
solve(1, n, ask(1, n));
}
int main() {
int t, n;
scanf("%d", &t);
while (t--) work();
return 0;
}
Details
answer.code: In function ‘void solve(int, int, int)’: answer.code:11:39: error: ‘x’ was not declared in this scope 11 | if (l == r) {printf("! %d\n", x); return;} | ^ answer.code: In function ‘int ask(int, int)’: answer.code:7:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int res; scanf("%d", &res); | ~~~~~^~~~~~~~~~~~ answer.code: In function ‘void work()’: answer.code:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d", &t); | ~~~~~^~~~~~~~~~