Submission #882888

#TimeUsernameProblemLanguageResultExecution timeMemory
882888MatjazMiners (IOI07_miners)C++14
100 / 100
637 ms110720 KiB
// // MinersIOI2007.cpp // // // Created by Matjaz Leonardis on 04/12/2023. // #include <iostream> #include <string> #include <vector> #include <string.h> using namespace std; // Trying all the different Miners solutions int N; string food; vector<int> f; int dp[100005][16][16]; int product(int state, int shipment){ vector<int> shipments; shipments.push_back(shipment); shipments.push_back(state % 4); shipments.push_back(state / 4); bool one = false, two= false, three=false; for (int i=0;i<shipments.size();i++){ if (shipments[i] == 1) one = true; if (shipments[i] == 2) two = true; if (shipments[i] == 3) three = true; } return one + two + three; } int coal(int x, int mine1, int mine2){ if (x >= N) return 0; if (dp[x][mine1][mine2] != -1) return dp[x][mine1][mine2]; int tomine1 = product(mine1, f[x]) + coal(x + 1, mine1 / 4 + 4 * f[x], mine2); int tomine2 = product(mine2, f[x]) + coal(x + 1, mine1, mine2 / 4 + 4 * f[x]); return dp[x][mine1][mine2] = max(tomine1, tomine2); } int main(){ memset(dp, -1, sizeof(dp)); cin >> N; cin >> food; f.assign(N, 0); for (int i=0;i<N;i++){ if (food[i] == 'B') f[i] = 1; if (food[i] == 'M') f[i] = 2; if (food[i] == 'F') f[i] = 3; } cout << coal(0,0,0) << endl; return 0; }

Compilation message (stderr)

miners.cpp: In function 'int product(int, int)':
miners.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0;i<shipments.size();i++){
      |                  ~^~~~~~~~~~~~~~~~~
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...