// moreflags=grader.cpp
// 6
#include "koala.h"
#if not LOCAL
#define NDEBUG
#endif
#include<vector>
#include<cassert>
#include<algorithm>
#if LOCAL
#include<cstdio>
#endif
std::vector<int>& play(std::vector<int>& data, std::vector<int>& result){
assert(result.size()==data.size());
playRound(data.data(), result.data());
return result;
}
std::vector<int> play(std::vector<int>& data){
std::vector<int> result(data.size());
play(data, result);
return result;
}
int minValue(int N, int W) {
assert(N==W);
std::vector<int> data(N);
data[0]=1;
auto result=play(data);
for(int i=0; i<N; ++i)
if(result[i]<=data[i])
return i;
}
int maxValue(int N, int W) {
std::vector<int> data(N, 1);
std::vector<int> result(N);
while(true){
auto c=(int)std::count_if(begin(data), end(data),[&](int it){return it>0;});
if(c==1)
return int(std::find_if(begin(data), end(data),[&](int it){return it>0;})-data.begin());
int value=W/c;
while([&]{
int tmp=0;
for(int i=N-c; i>N-c-value; --i) tmp+=i;
return tmp;
}()>=N) {
--value;
assert(value>=1);
}
for(auto& it: data)
if(it>0) it=W/c;
play(data, result);
for(int i=0; i<N; ++i)
if(result[i]<=data[i])
data[i]=0;
}
}
int greaterValue(int N, int W) {
std::vector<int> data(N), result(N);
auto const check=[&](int value){
assert(value>0);
value+=value>=6;
data[0]=data[1]=value;
play(data, result);
if(result[0]>data[0] and result[1]>data[1]){
return 2;
}else if(result[0]<=data[0] and result[1]<=data[1]){
return 0;
}else{
return 1;
}
};
#if LOCAL
for(int i=1; i<12; ++i)
std::fprintf(stderr, "%d", check(i));
std::fprintf(stderr, "\n");
return 0;
#endif
int k=0;
for(auto step=1<<3;;){
step>>=1;
assert(step!=0);
switch(check(k+step)){
case 2: k+=step; break;
case 0: break;
case 1:
if(result[0]>data[0]) return 0; else return 1;
}
}
}
void allValues(int N, int W, int *P) {
if (W == 2*N) {
// TODO: Implement Subtask 4 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
}
Compilation message
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
384 KB |
Output is correct |
2 |
Correct |
18 ms |
384 KB |
Output is correct |
3 |
Correct |
18 ms |
256 KB |
Output is correct |
4 |
Correct |
18 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
384 KB |
Output is correct |
2 |
Correct |
96 ms |
392 KB |
Output is correct |
3 |
Correct |
85 ms |
384 KB |
Output is correct |
4 |
Correct |
86 ms |
384 KB |
Output is correct |
5 |
Correct |
84 ms |
376 KB |
Output is correct |
6 |
Correct |
84 ms |
400 KB |
Output is correct |
7 |
Correct |
90 ms |
384 KB |
Output is correct |
8 |
Correct |
92 ms |
504 KB |
Output is correct |
9 |
Correct |
82 ms |
376 KB |
Output is correct |
10 |
Correct |
81 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |