#include "grader.h"
#include <vector>
#include <stdio.h>
std::vector<int> v;
std::vector<int> res;
void solve(int n) {
int val, l, r, mij, i, ans;
res.clear();
res.reserve(n);
for(val = 1; val <= n; val++) {
l = 0;
r = n - 1;
while(l < r) {
mij = (l + r) / 2;
v.clear();
v.reserve(n);
for(i = 0; i < n; i++) {
v[i] = n + 1;
}
for(i = l; i <= mij; i++) {
v[i] = val;
}
ans = query(v);
if(ans == 0) {
l = mij + 1;
} else {
r = mij;
}
}
res[l] = val;
}
query(res);
}
/*
int perm[10000];
int query(std::vector<int> v) {
int i, res;
res = 0;
for(i = 0; i < (int)v.size(); i++) {
res += v[i] != perm[i];
printf("%d ", v[i]);
}
printf("\n");
return res;
}
int main() {
int n, i;
scanf("%d", &n);
for(i = 0; i < n; i++) {
scanf("%d", &perm[i]);
}
solve(n);
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |