# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
511090 |
2022-01-15T05:50:56 Z |
Sharky |
Miners (IOI07_miners) |
C++17 |
|
422 ms |
716 KB |
#include <bits/stdc++.h>
// --------------------
#define sharky using namespace
#define fai std
#define wrong ios_base::sync_with_stdio(0);
#define answer cin.tie(0);
// --------------------
sharky fai;
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define sz(x) (ll) (x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define vll vector<ll>
#define pl pair<ll, ll>
const ll inf = 1e18;
const int MOD = 1e9 + 7;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
ll f(ll x, ll y, ll z) {
ll ans = 0;
for (ll i = 1; i <= 3; i++) {
if (x == i || y == i || z == i) {
ans++;
}
}
return ans;
}
ll dp[2][4][4][4][4];
int main() {
wrong answer
ll n; cin >> n >> ws; vector<int> v(n + 5);
for (ll i = 0; i < n; i++) {
char c; cin >> c;
switch (c) {
case 'B': { v[i + 1] = 1; break; }
case 'F': { v[i + 1] = 2; break; }
case 'M': { v[i + 1] = 3; break; }
}
// cout << v[i + 1] << endl;
}
for (ll i = n; i >= 1; i--) {
for (ll w = 0; w <= 3; w++) {
for (ll x = 0; x <= 3; x++) {
for (ll y = 0; y <= 3; y++) {
for (ll z = 0; z <= 3; z++) {
int k = 1 - (i & 1);
if (i == n) {
dp[k][w][x][y][z] = max(f(w, x, v[i]), f(y, z, v[i]));
} else {
dp[k][w][x][y][z] = max(dp[1 - k][x][v[i]][y][z] + f(w, x, v[i]), dp[1 - k][w][x][z][v[i]] + f(y, z, v[i]));
}
}
}
}
}
}
cout << dp[0][0][0][0][0] << endl;
return 0;
}
/*
dp[i][j][k][jj][kk] = if i is the current el, j is 1st type and k is 2nd type and jj kk for 2nd mine?
max produced food
dp[i][j][k][jj][kk] = max(dp[i - 1][k]][s[i]][jj][kk] + f(j, k, s[i]), same for other mine)
rolling array (16mb)?
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
259 ms |
584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
422 ms |
716 KB |
Output is correct |