Submission #404243

#TimeUsernameProblemLanguageResultExecution timeMemory
404243Haruto810198Koala Game (APIO17_koala)C++17
47 / 100
62 ms336 KiB
#include <bits/stdc++.h> #include "koala.h" using namespace std; //#define int long long #define double long double #define FOR(i,l,r,d) for(int i=(l);i<=(r);i+=(d)) #define szof(x) ((x).size()) #define vi vector<int> #define pii pair<int,int> #define F first #define S second #define pb push_back #define eb emplace_back #define mkp make_pair const int INF = 2147483647; const int MOD = 1000000007; const int mod = 998244353; const double eps = 1e-12; int B[100]; int R[100]; int minValue(int N, int W) { // TODO: Implement Subtask 1 solution here. // You may leave this function unmodified if you are not attempting this // subtask. FOR(i,0,N-2,1){ B[i] = 0; } B[N-1] = 1; playRound(B, R); int res = 0; FOR(i,0,N-1,1){ if(R[i]<=B[i]){ res = i; } } return res; } int maxValue(int N, int W) { // TODO: Implement Subtask 2 solution here. // You may leave this function unmodified if you are not attempting this // subtask. bool isMax[N]; /// Round 0: 100 -> 50 /// Round 1: 50 -> 25 /// Round 2: 25 -> 9 /// Round 3: 9 -> 1 int Maxstone[4] = {1, 2, 4, 11}; FOR(i,0,N-1,1){ isMax[i] = 1; } FOR(Round,0,3,1){ FOR(i,0,N-1,1){ if(isMax[i]==1){ B[i] = Maxstone[Round]; } else{ B[i] = 0; } } playRound(B, R); FOR(i,0,N-1,1){ if(R[i]>B[i] and isMax[i]==1){ isMax[i] = 1; } else{ isMax[i] = 0; } } } FOR(i,0,N-1,1){ if(isMax[i]){ return i; } } return 0; } int greaterValue(int N, int W) { // TODO: Implement Subtask 3 solution here. // You may leave this function unmodified if you are not attempting this // subtask. FOR(i,2,N-1,1){ B[i] = 0; } int lb=1, rb=14, mid; while(lb<rb){ mid = (lb+rb) / 2; B[0] = B[1] = mid; playRound(B, R); if(R[0]>B[0] and R[1]>B[1]){ lb = mid+1; } else if(R[0]<=B[0] and R[1]<=B[1]){ rb = mid-1; } else{ if(R[0]>B[0]){ return 0; } else{ return 1; } } } return 0; } bool cmp(int n1, int n2){ FOR(i,0,99,1){ B[i] = 0; } B[n1] = B[n2] = 100; playRound(B, R); return (R[n1]<R[n2]); } 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. int rk[100]; FOR(i,0,99,1){ rk[i] = i; } stable_sort(rk,rk+100,cmp); FOR(i,0,99,1){ P[rk[i]] = i + 1; } } else { // TODO: Implement Subtask 5 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...