| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 837453 | borisAngelov | Miners (IOI07_miners) | C++17 | 151 ms | 134084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
string s;
int a[maxn];
int dp[maxn][4][4][4][4];
bool bl[maxn][4][4][4][4];
int calc(int x, int y, int z)
{
int result = 3;
if (y == 0 || y == x)
{
--result;
}
if (z == 0 || z == x)
{
--result;
}
if (y == z && y != x && z != x && y != 0 && z != 0)
{
result = 2;
}
return result;
}
int f(int pos, int last1, int second1, int last2, int second2)
{
if (pos == n)
{
return 0;
}
if (bl[pos][last1][second1][last2][second2] == true)
{
return dp[pos][last1][second1][last2][second2];
}
bl[pos][last1][second1][last2][second2] = true;
int result = calc(a[pos], last1, second1) + f(pos + 1, a[pos], last1, last2, second2);
result = max(result, calc(a[pos], last2, second2) + f(pos + 1, last1, second1, a[pos], last2));
return dp[pos][last1][second1][last2][second2] = result;
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> s;
for (int i = 0; i < n; ++i)
{
if (s[i] == 'M')
{
a[i] = 1;
}
if (s[i] == 'B')
{
a[i] = 2;
}
if (s[i] == 'F')
{
a[i] = 3;
}
}
cout << f(0, 0, 0, 0, 0) << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
