Submission #330656

#TimeUsernameProblemLanguageResultExecution timeMemory
330656caoashPlaninarenje (COCI18_planinarenje)C++17
0 / 160
317 ms1036 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define lb lower_bound #define ub upper_bound using pi = pair<int,int>; #define f first #define s second #define mp make_pair const int MX = 5005; const int MOD = (int) (1e9 + 7); const ll INF = (ll) 1e18; int done[MX]; int pa[MX], pb[MX]; int it = 0; vi adj[MX]; bool dfs(int v) { done[v] = it; for (int to : adj[v]) { if (pb[to] == -1) { pa[v] = to; pb[to] = v; return true; } } for (int to : adj[v]) { if (done[pb[to]] != it && dfs(pb[to])) { pa[v] = to; pb[to] = v; return true; } } return false; } int main(){ #ifdef mikey freopen("a.in", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--, v--; adj[u].pb(v); } memset(pa, -1, sizeof(pa)); memset(pb, -1, sizeof(pb)); auto aug = [&] () { int mm = 0; for (int i = 0; i < n; i++) { if (pa[i] == -1 && dfs(i)) ++mm; } return mm; }; int best = 0; int add = 0; do { add = aug(); best += add; } while (add > 0); for (int i = 0; i < n; i++) { int nbest = best - 1; int old = pa[i]; pa[i] = -1, pb[old] = -1; do { add = aug(); nbest += add; } while (add > 0); assert(nbest <= best); if (nbest == best) { cout << "Slavko\n"; } else { cout << "Mirko\n"; } pa[i] = old, pb[old] = i; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...