# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
372733 | Drew_ | Miners (IOI07_miners) | C++14 | 155 ms | 100864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second
#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using pl = pair<ll, ll>;
ld const PI = 4*atan((ld)1);
const int MAX = 1e5 + 7;
int dp[MAX][4][4][4][4];
int main()
{
fastio;
memset(dp, -1, sizeof(dp));
int n;
cin >> n;
string s;
cin >> s;
dp[0][0][0][0][0] = 0;
for (int i = 0; i < n; ++i)
{
int nxt;
if (s[i] == 'M') nxt = 1;
if (s[i] == 'B') nxt = 2;
if (s[i] == 'F') nxt = 3;
for (int a = 0; a <= 3; ++a)
{
for (int b = 0; b <= 3; ++b)
{
for (int c = 0; c <= 3; ++c)
{
for (int d = 0; d <= 3; ++d)
{
if (dp[i][a][b][c][d] == -1)
continue;
int coal;
//giving to the first mine
coal = 0;
for (int x = 1; x <= 3; ++x)
coal += (x == a || x == b || x == nxt);
dp[i+1][b][nxt][c][d] = max(dp[i+1][b][nxt][c][d], coal + dp[i][a][b][c][d]);
//giving to the second mine
coal = 0;
for (int x = 1; x <= 3; ++x)
coal += (x == c || x == d || x == nxt);
dp[i+1][a][b][d][nxt] = max(dp[i+1][a][b][d][nxt], coal + dp[i][a][b][c][d]);
}
}
}
}
}
int res = 0;
for (int a = 0; a <= 3; ++a)
for (int b = 0; b <= 3; ++b)
for (int c = 0; c <= 3; ++c)
for (int d = 0; d <= 3; ++d)
res = max(res, dp[n][a][b][c][d]);
cout << res << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |