# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448668 | prvocislo | Game (eJOI20_game) | C++17 | 9 ms | 1348 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 <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
const int inf = 1e9 + 5, maxn = 21;
vector<int> cycles, paths;
map<vector<int>, int> m;
void chmin(int& a, const int& b) { a = min(a, b); }
void chmax(int& a, const int& b) { a = max(a, b); }
int solve(int ic, int ip, int left, int typ) // typ = -1 ak to je uz odseknute, 0 je cesta, 1 je cyklus
{
if (ic+1 == cycles.size() && ip+1 == paths.size()) return left;
if (m.count({ ic, ip, left, typ })) return m[{ic, ip, left, typ }];
int &ans = m[{ic, ip, left, typ }] = -inf;
if (typ == 0 && left > 2) chmax(ans, left - 2 - solve(ic, ip, 2, -1));
if (typ == 1 && left >= 4) chmax(ans, left - 4 - solve(ic, ip, 4, -1));
if (ic + 1 != cycles.size())
chmax(ans, left - solve(ic + 1, ip, cycles[ic + 1], 1));
if (ip + 1 != paths.size())
chmax(ans, left - solve(ic, ip + 1, paths[ip + 1], 0));
return ans;
}
vector<vector<int> > g(maxn * maxn);
vector<string> h(maxn), v(maxn);
vector<bool> vis(maxn * maxn, false);
int r, c;
void dfs(int u, int& cntv, int& cnte)
{
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |