Submission #1133009

#TimeUsernameProblemLanguageResultExecution timeMemory
1133009Math4Life2020Koala Game (APIO17_koala)C++20
Compilation error
0 ms0 KiB
//#include "koala.h" #include <bits/stdc++.h> using namespace std; using ll = int; using pii = pair<ll,ll>; const int N = 100; //playRound(a,b): int a[N] (you enter this in), int b[N] (it enters this in) int minValue(int N1, int W) { int a[N],b[N]; for (int i=0;i<N;i++) { a[i]=1; } playRound(a,b); ll xm = -1; for (int i=0;i<N;i++) { if (b[i]==2) { xm = i; } } for (int i=0;i<N;i++) { a[i]=0; if (i==xm) { a[i]=1; } } playRound(a,b); for (int i=0;i<N;i++) { if (b[i]==0) { return i; } } } int maxValue(int N1, int W) { int a[N],b[N]; for (int i=0;i<N;i++) { a[i]=1; } playRound(a,b); int topHalf[N]; for (int i=0;i<N;i++) { topHalf[i]=(b[i]==2); a[i]=b[i]; } //nvm this is wrong playRound(a,b); int qtrIdx[N]; //quarter index: //0 -> [1,25] (a=0,b=0) //1 -> [26,50] (a=0,b=1) //2 -> [51,75] (a=2,b=0) //3 -> [76,100] (a=2,b=3) for (int i=0;i<N;i++) { if (a[i]==0 && b[i]==0) { qtrIdx[i]=0; }else if (a[i]==0 && b[i]==1) { qtrIdx[i]=1; }else if (a[i]==2 && b[i]==0) { qtrIdx[i]=2; }else if (a[i]==2 && b[i]==3) { qtrIdx[i]=3; }else { assert(1==2); } } //put 3 in a: [76,100] -> b: put 50 into 1,2 and then remaining ones go into: //[20,25] -> 6, [90,100] -> 4*11=44 //sumE = 1180 //[24,25] -> 2, [89,100] -> 4*12=48 //sumE = 1183 for (int i=0;i<N;i++) { a[i]=3*(qtrIdx[i]==3); } playRound(a,b); vector<int> v1,v2; //[76,88] and [89,100] for (int i=0;i<N;i++) { if (qtrIdx[i]==4) { if (b[i]==1) { v2.push_back(i); } else { v1.push_back(i); } } } assert(v2.size()==12); for (int i=0;i<N;i++) { a[i]=(qtrIdx[i]==2); } for (int t=0;t<7;t++) { a[v1[t]]=1; } for (int t: v2) { a[t]=3; } playRound(a,b); //intervals: [1,25]->0, cost 1, [26,50] cost 25, [51,88] -> 32*1+6*0=32, cost 64+6=70, [89,100]->12*3=36, cost 4 for (int t: v2) { if (b[t]==4) { return t; } } } 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. return 0; } 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 minValue(int, int)':
koala.cpp:15:4: error: 'playRound' was not declared in this scope; did you mean 'lround'?
   15 |    playRound(a,b);
      |    ^~~~~~~~~
      |    lround
koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:41:5: error: 'playRound' was not declared in this scope; did you mean 'lround'?
   41 |     playRound(a,b);
      |     ^~~~~~~~~
      |     lround
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:103:1: warning: control reaches end of non-void function [-Wreturn-type]
  103 | }
      | ^