Submission #200164

#TimeUsernameProblemLanguageResultExecution timeMemory
200164SaboonPlaninarenje (COCI18_planinarenje)C++14
160 / 160
22 ms764 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 5000 + 37; int match[maxn], fmatch[maxn]; vector<int> g[maxn]; bool visited[maxn]; bool dfs(int v){ if (v == 0 or visited[v] == true) return false; visited[v] = true; for (auto u : g[v]){ if (match[u] == -1 or dfs(match[u])){ match[u] = v; fmatch[v] = u; return true; } } return false; } int main(){ ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 0; i < m; i++){ int v, u; cin >> v >> u; g[u].push_back(v); } memset(fmatch, -1, sizeof fmatch); memset(match, -1, sizeof match); for (int i = 1; i <= n; i++){ memset(visited, 0, sizeof visited); dfs(i); } for (int i = 1; i <= n; i++){ if (match[i] == -1){ cout << "Mirko\n"; continue; } int v = match[i]; fmatch[match[i]] = -1; match[i] = 0; memset(visited, 0, sizeof visited); if (dfs(v)){ cout << "Mirko\n"; match[i] = -1; continue; } cout << "Slavko\n"; } }
#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...