Submission #643672

# Submission time Handle Problem Language Result Execution time Memory
643672 2022-09-22T18:27:32 Z ErXiM Miners (IOI07_miners) C++14
0 / 100
26 ms 1612 KB
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 1e5+5;

int n;
int dostawy[MAXN];
int dp[2][4][4][4];

inline int ore (int a, int b, int c) {
    int x = 0;
    if (a == 1 || b == 1 || c == 1){
        x++;
    }
    if (a == 2 || b == 2 || c == 2){
        x++;
    }
    if (a == 3 || b == 3 || c == 3){
        x++;
    }
    return x;
}
int main() {
    int n;
    cin >> n;
    string input;
    cin >> input;
    for(int i = 0;i<n;i++){
        if(input[i]=='M'){
            dostawy[i] = 1;
        }
        else if(input[i]=='F'){
            dostawy[i] = 2;
        }
        else{
            dostawy[i] = 3;
        }
    }
    int cur = 0; int prev = 1;
    for(int k=n-1; k>=0; k--){ //looking at deliveries from the back
       for(int a=0; a<=3; a++){
          for(int b=0; b<=3; b++){
             for (int c=0; c<=3; c++){
                int left = ore(dostawy[k], dostawy[k-1], a) + dp[prev][dostawy[k-1]][b][c];
                int right = ore(dostawy[k], b, c) + dp[prev][b][dostawy[k-1]][a];
                dp[cur][a][b][c] = max(left, right);
             }
          }
       }

       swap(cur,prev);
    }
    cout << dp[1-cur][0][0][0];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 500 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 712 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 1304 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 1612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -