# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260139 | 2020-08-09T11:30:13 Z | user202729 | Koala Game (APIO17_koala) | C++17 | 0 ms | 0 KB |
// 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(0){ for(int i=1; i<12; ++i) std::fprintf(stderr, "%d", check(i)); std::fprintf(stderr, "\n"); return 0; } 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. } }