Submission #584549

# Submission time Handle Problem Language Result Execution time Memory
584549 2022-06-27T14:29:08 Z Kanaifu Miners (IOI07_miners) C++14
0 / 100
74 ms 32720 KB
#include <bits/stdc++.h>

using namespace std;

int arr[100001];

unordered_map<int,int> dp[4][4][4][4];

int n;

int rec(int pos, int last_l, int plast_l, int last_r, int plast_r)
{
    if (pos == n)
    {
        return 0;
    }
    if (dp[last_l][plast_l][last_r][plast_r][pos] != 0)
    {
        return dp[last_l][plast_l][last_r][plast_r][pos];
    }
    int inc = 1;
    if (last_l != arr[pos] and last_l != 0)
    {
        inc++;
    }
    if (plast_l != arr[pos] and plast_l != last_l and plast_l != 0)
    {
        inc++;
    }
    dp[last_l][plast_l][last_r][plast_r][pos] = rec(pos+1, arr[pos], last_l, last_r, plast_r) + inc;

    inc = 1;
    if (last_r != arr[pos] and last_r != 0)
    {
        inc++;
    }
    if (plast_r != arr[pos] and plast_r != last_r and plast_r != 0)
    {
        inc++;
    }
    dp[last_l][plast_l][last_r][plast_r][pos] = max (dp[last_l][plast_l][last_r][plast_r][pos], rec(pos+1, last_l, plast_l, arr[pos], last_r) + inc);
    return dp[last_l][plast_l][last_r][plast_r][pos];
}

int main()
{
    cin>>n;
    for (int i=0; i<n; i++)
    {
        char c;
        cin>>c;
        if (c=='R')
        {
            arr[i] = 1;
        }
        else if (c=='Y')
        {
            arr[i] = 2;
        }
        else
        {
            arr[i] = 3;
        }
    }
    cout<<rec(0, 0, 0, 0, 0);
}
# 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 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 240 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 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 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 3180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 8332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 22732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 32720 KB Output isn't correct
2 Halted 0 ms 0 KB -