# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171299 | dennisstar | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++11 | 222 ms | 196768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ryan bear
#define now mem[co][r][g][y]
#define all(V) ((V).begin()), ((V).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<int> vim;
typedef vector<ll> vlm;
int n, ar[410], mem[3][410][410][410], cnt[3][410];
char s[410];
vim c[3];
int f(int co, int r, int g, int y) {
if (!(r+g+y)) return 0;
if (now!=-1) return now;
now=(1<<30);
if (r&&co==0) now = min( now , min(f(1, r-1, g, y), f(2, r-1, g, y))+abs(g-cnt[1][c[0][r-1]])+abs(y-cnt[2][c[0][r-1]]));
if (g&&co==1) now = min( now , min(f(0, r, g-1, y), f(2, r, g-1, y))+abs(r-cnt[0][c[1][g-1]])+abs(y-cnt[2][c[1][g-1]]));
if (y&&co==2) now = min( now , min(f(0, r, g, y-1), f(1, r, g, y-1))+abs(r-cnt[0][c[2][y-1]])+abs(g-cnt[1][c[2][y-1]]));
return now;
}
int main() {
scanf("%d %s", &n, s);
Compilation message (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... |