#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
int fw[505];
void update(int x, int v) {
for(x++; x < 505; x += x&-x) fw[x] += v;
}
int query(int x) {
int ans = 0;
for(x++; x; x -= x&-x) ans += fw[x];
return ans;
}
void Solve(int N) {
for(int i = 0; i < N; i++) {
int l = 1, r = 2*N, m;
while(l < r) {
m = (l+r)/2;
vector<int> v;
for(int j = 1; j <= m; j++) v.push_back(j);
int q = Query(v);
if(q >= m-query(m)) l = m+1;
else r = m;
}
int second = l, first = -1;
for(int j = 1; j < second; j++) {
vector<int> v;
v.push_back(j); v.push_back(second);
if(Query(v) == 1) {
first = j; break;
}
}
update(second, 1);
Answer(first, second);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
17 ms |
460 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
17 ms |
460 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |