Submission #409305

#TimeUsernameProblemLanguageResultExecution timeMemory
409305myrcellaKoala Game (APIO17_koala)C++17
37 / 100
73 ms348 KiB
#include "koala.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} int a[100],b[100]; void playRound(int *B, int *R); 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. memset(a,0,sizeof(a)); a[0]=1; playRound(a,b); rep(i,0,N) if (b[i]<=a[i]) return i; } int flag[100]; 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. memset(flag,0,sizeof(flag)); rep(i,0,N) a[i]=1; playRound(a,b); rep(i,0,N) if (b[i]>a[i]) flag[i]++; else flag[i]=-233; rep(i,0,N) if (flag[i]==1) a[i]=2;else a[i]=0; playRound(a,b); rep(i,0,N) if (flag[i]==1&&b[i]>a[i]) flag[i]++; else flag[i]=-233; rep(i,0,N) if (flag[i]==2) a[i]=4;else a[i]=0; playRound(a,b); rep(i,0,N) if (flag[i]==2&&b[i]>a[i]) flag[i]++; rep(i,0,N) if (flag[i]==3) a[i]=11;else a[i]=0; playRound(a,b); rep(i,0,N) if (flag[i]==3&&b[i]>a[i]) return i; return 0; } int greaterValue(int N, int W) { int l=1,r=14; // while ((1+r)*r/2<N+N-1) r++; r--; memset(a,0,sizeof(a)); while (l<r) { int mid=l+r>>1; a[0]=a[1]=mid; playRound(a,b); if (b[0]<=a[0]&&b[1]<=a[1]) r=mid-1; else if (b[0]>a[0]&&b[1]>a[1]) l=mid+1; else return b[0]>a[0]?0:1; } // TODO: Implement Subtask 3 solution here. // You may leave this function unmodified if you are not attempting this // subtask. } 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 (stderr)

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:66:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   66 |   int mid=l+r>>1;
      |           ~^~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
   76 | }
      | ^
#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...