#include <bits/stdc++.h>
#include "koala.h"
using namespace std;
typedef long long ll;
int minValue(int n, int w){
int A[102] = {1};
int B[102] = {0};
playRound(A, B);
for(int i=0; i<n; i++){
if(B[i] <= A[i]) return i;
}
exit(1);
}
int maxValue(int n, int W) {
vector<int> candidate;
for(int i=0; i<n; i++) candidate.push_back(i);
while((int)candidate.size() > 1){
int tmp = W / (int)candidate.size();
int A[102] = {0};
int B[102] = {0};
for(auto cand: candidate) A[cand] = tmp;
playRound(A, B);
candidate.clear();
for(int i=0; i<n; i++) if(B[i] > tmp) candidate.push_back(i);
}
return candidate[0];
}
int greaterValue(int N, int W) {
int MIN = 1, MAX = 9;
while(MIN <= MAX){
int MID = (MIN + MAX) / 2;
int A[102] = {MID, MID};
int B[102] = {0};
playRound(A, B);
if(B[0] > MID && B[1] > MID) MIN = MID + 1;
else if(B[0] <= MID && B[1] <= MID) MAX = MID - 1;
else return B[0] < B[1];
}
exit(1);
}
int w;
void solve(int n, int *P, int l, int r, vector<int>& v){
if(l==r){
P[v[0]] = l+1;
return;
}
int tmp = min((int)sqrt(2*(l+1)), n / (r-l+1));
int A[102] = {0};
int B[102] = {0};
for(auto i: v) A[i] = tmp;
playRound(A, B);
vector<int> v1, v2;
for(auto i: v){
if(B[i] > tmp) v2.push_back(i);
else v1.push_back(i);
}
solve(n, P, l, l + (int)v1.size() - 1, v1);
solve(n, P, r - (int)v2.size() + 1, r, v2);
}
void allValues(int N, int W, int *P) {
if(w==N){
vector<int> vec (N);
for(int i=0; i<N; i++) vec[i] = i;
solve(N, P, 0, N-1, vec);
}
else{
int idx[102];
for(int i=0; i<N; i++) idx[i] = i;
sort(idx, idx+N, [&](int x, int y){
int A[102]={0};
int B[102]={0};
A[x] = A[y] = N;
playRound(A, B);
return B[y] > N;
});
for(int i=0; i<N; i++){
P[idx[i]] = i+1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
5 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
5 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
364 KB |
Output is correct |
2 |
Correct |
18 ms |
364 KB |
Output is correct |
3 |
Correct |
20 ms |
364 KB |
Output is correct |
4 |
Correct |
21 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
512 KB |
Output is correct |
2 |
Correct |
84 ms |
364 KB |
Output is correct |
3 |
Correct |
70 ms |
364 KB |
Output is correct |
4 |
Correct |
71 ms |
364 KB |
Output is correct |
5 |
Correct |
74 ms |
364 KB |
Output is correct |
6 |
Correct |
72 ms |
492 KB |
Output is correct |
7 |
Correct |
71 ms |
364 KB |
Output is correct |
8 |
Correct |
73 ms |
364 KB |
Output is correct |
9 |
Correct |
73 ms |
364 KB |
Output is correct |
10 |
Correct |
70 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
364 KB |
Output is correct |
2 |
Incorrect |
62 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |