#include "koala.h"
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) x.size())
using namespace std;
int B[100]; int R[100];
int minValue(int N, int W) {
fill(B,B+N,0); B[0] = 1;
playRound(B,R);
for(int i = 0;i < N;i++){
if(R[i] == 0) return i;
}
return -1;
}
int big[105];
int maxValue(int n, int W) {
fill(big,big+n,1);
vector<int> witness = {1,2,4,11};
for(int x : witness){
for(int i = 0;i < n;i++){
if(big[i]) B[i] = x;
else B[i] = 0;
}
playRound(B,R);
for(int i = 0;i < n;i++){
if(R[i] == 0) big[i] = 0;
}
for(int i = 0;i < n;i++) { cerr << R[i] << " "; } cerr << endl;
}
for(int i = 0;i < n;i++) if(big[i]) return i;
return 0;
}
int greaterValue(int n, int W){
vector<int> witness = {1,2,3,5,6,7,8};
int pos = 0;
for(int s = 4;s >= 1;s /= 2){
int x = witness[pos+s-1];
cerr << x << endl;
B[0] = x;
B[1] = x;
playRound(B,R);
if(R[0] > R[1]) return 0;
if(R[1] > R[0]) return 1;
if(R[0] != 0) pos += s;
}
return -1;
}
void allValues1(int n, int W, int *P){
int B[n]; int R[n]; int A[n];
for(int i = 0;i < n;i++) A[i] = i;
stable_sort(A, A+n, [&](int a, int b){
fill(B,B+n,0);
B[a] = n, B[b] = n;
playRound(B,R);
if(R[a] == 0) return true;
else return false;
});
for(int i = 0;i < n;i++) P[A[i]] = i+1;
}
int precompX[100] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 3, 3, 1, 3, 1, 1, 2, 3, 4, 2, 3, 4, 4, 1, 2, 3, 3, 4, 1, 5, 1, 2, 2, 3, 5, 3, 4, 5, 2, 5, 2, 3, 4, 5, 4, 4, 6, 1, 2, 3, 5, 6, 3, 4, 6, 5, 6, 1, 4, 5, 6, 1, 7, 1, 2, 2, 2, 3, 4, 5, 7, 3, 4, 7, 5, 6, 7, 2, 5, 6, 7, 2, 2, 3, 4, 5, 6, 8, 3, 4, 6, 8, 5, 8, 6, 8};
int cnt = 0;
void allValues2(int n, int *P, int s, int e, vector<int> stuff){
if(sz(stuff) == 1){
P[stuff[0]] = s;
return;
}
int X = precompX[cnt]; cnt++;
fill(B,B+n,0);
for(int i : stuff) B[i] = X;
playRound(B,R);
vector<int> left, right;
for(int i : stuff){
if(R[i] == 0) left.push_back(i);
else right.push_back(i);
}
if(sz(left) != 0 and sz(right) != 0){
//cerr << X << ", ";
int m = s + sz(left);
allValues2(n, P, s, m-1, left);
allValues2(n, P, m, e, right);
return;
}
}
void allValues(int N, int W, int *P) {
if (W == 2*N) allValues1(N, W, P);
else{
vector<int> stuff;
for(int i = 0;i < N;i++) stuff.push_back(i);
allValues2(N, P, 1, N, stuff);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
760 KB |
Output is correct |
2 |
Correct |
116 ms |
496 KB |
Output is correct |
3 |
Correct |
98 ms |
488 KB |
Output is correct |
4 |
Correct |
95 ms |
496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
472 KB |
Output is correct |
2 |
Correct |
61 ms |
468 KB |
Output is correct |
3 |
Correct |
44 ms |
480 KB |
Output is correct |
4 |
Correct |
71 ms |
472 KB |
Output is correct |
5 |
Correct |
45 ms |
476 KB |
Output is correct |
6 |
Correct |
45 ms |
476 KB |
Output is correct |
7 |
Correct |
49 ms |
472 KB |
Output is correct |
8 |
Correct |
47 ms |
504 KB |
Output is correct |
9 |
Correct |
46 ms |
492 KB |
Output is correct |
10 |
Correct |
44 ms |
740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
344 KB |
Output is correct |
2 |
Correct |
28 ms |
344 KB |
Output is correct |
3 |
Correct |
28 ms |
428 KB |
Output is correct |
4 |
Correct |
30 ms |
344 KB |
Output is correct |
5 |
Correct |
27 ms |
344 KB |
Output is correct |
6 |
Correct |
27 ms |
452 KB |
Output is correct |
7 |
Correct |
30 ms |
344 KB |
Output is correct |
8 |
Correct |
27 ms |
340 KB |
Output is correct |
9 |
Correct |
28 ms |
344 KB |
Output is correct |
10 |
Correct |
26 ms |
452 KB |
Output is correct |
11 |
Correct |
33 ms |
344 KB |
Output is correct |
12 |
Correct |
12 ms |
344 KB |
Output is correct |
13 |
Correct |
26 ms |
344 KB |
Output is correct |
14 |
Correct |
24 ms |
344 KB |
Output is correct |
15 |
Correct |
24 ms |
344 KB |
Output is correct |
16 |
Correct |
32 ms |
344 KB |
Output is correct |
17 |
Correct |
31 ms |
344 KB |
Output is correct |
18 |
Correct |
26 ms |
344 KB |
Output is correct |
19 |
Correct |
25 ms |
344 KB |
Output is correct |
20 |
Correct |
31 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
344 KB |
Output is correct |
11 |
Correct |
3 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
460 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
3 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
344 KB |
Output is correct |
17 |
Correct |
3 ms |
344 KB |
Output is correct |
18 |
Correct |
3 ms |
344 KB |
Output is correct |
19 |
Correct |
2 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
3 ms |
344 KB |
Output is correct |
22 |
Correct |
3 ms |
344 KB |
Output is correct |
23 |
Correct |
3 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
3 ms |
344 KB |
Output is correct |
26 |
Correct |
3 ms |
344 KB |
Output is correct |
27 |
Correct |
4 ms |
460 KB |
Output is correct |
28 |
Correct |
3 ms |
344 KB |
Output is correct |
29 |
Correct |
3 ms |
456 KB |
Output is correct |
30 |
Correct |
3 ms |
344 KB |
Output is correct |
31 |
Correct |
3 ms |
344 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
3 ms |
460 KB |
Output is correct |
34 |
Correct |
3 ms |
344 KB |
Output is correct |
35 |
Correct |
3 ms |
344 KB |
Output is correct |
36 |
Correct |
2 ms |
344 KB |
Output is correct |
37 |
Correct |
3 ms |
344 KB |
Output is correct |
38 |
Correct |
3 ms |
344 KB |
Output is correct |
39 |
Correct |
3 ms |
460 KB |
Output is correct |
40 |
Correct |
4 ms |
344 KB |
Output is correct |