Submission #584537

# Submission time Handle Problem Language Result Execution time Memory
584537 2022-06-27T14:17:06 Z teki Miners (IOI07_miners) C++11
0 / 100
233 ms 108636 KB
#include <bits/stdc++.h>

typedef long long ll;

#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
const ll MN = 1000000007;

using namespace std;

int n;
int tip[100001];
int dp[100001][4][4][4][4];

int magic(int a, int b, int c) {
    unordered_set<int> brr;
    brr.insert(a);
    brr.insert(b);
    brr.insert(c);

    int res = 0;

    for (auto it:brr) if (it != 3) res++;

    return res;
}

int rek(int pos, int lastL, int plastL, int lastR, int plastR) {
    if (dp[pos][lastL][plastL][lastR][plastR] != -1) return dp[pos][lastL][plastL][lastR][plastR];
    if (pos >= n) return 0;

    int ret = rek(pos+1,tip[pos],lastL,lastR,plastR)+magic(lastL,plastL,tip[pos]);
    ret = max(ret,rek(pos+1,lastL,plastR,tip[pos],lastR)+magic(lastR,plastR,tip[pos]));

    return dp[pos][lastL][plastL][lastR][plastR] = ret;
}

int main()
{
    #if LOCAL_DEBUG
        fstream cin("in.txt");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    string s;
    cin>>s;

    for (int i = 0; i<n; i++) {
        if (s[i] == 'R') tip[i] = 0;
        else if (s[i] == 'Y') tip[i] = 1;
        else if (s[i] == 'G') tip[i] = 2;
    }

    MS(dp,-1);

    cout<<rek(0,3,3,3,3)<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 100420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 100432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 100432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 100484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 100372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 100504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 100564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 100804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 101208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 102536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 106636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 233 ms 108636 KB Output isn't correct
2 Halted 0 ms 0 KB -