Submission #227354

#TimeUsernameProblemLanguageResultExecution timeMemory
227354BRs82Planinarenje (COCI18_planinarenje)C++14
160 / 160
8 ms896 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; vector<int> gr[N]; int matchup[N], matchdw[N], n, m; bool ans[N], mark[N]; bool dfs(int v) { mark[v] = 1; for (auto u : gr[v]) { if (matchup[u] == -1 || (!mark[matchup[u]] && dfs(matchup[u]))) { matchup[u] = v; matchdw[v] = u; return true; } } return false; } void getCmp(int v) { mark[v] = 1; for (auto u : gr[v]) { if (!mark[matchup[u]]) getCmp(matchup[u]); } return; } int main() { ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; x--, y--; gr[x].push_back(y); } memset(matchup, -1, sizeof(matchup)); memset(matchdw, -1, sizeof(matchdw)); while (true) { bool z = false; for (int i = 0; i < n; i++) { if (!mark[i] && matchdw[i] == -1 && dfs(i)) { z = true; } } if (!z) break; memset(mark, 0, sizeof(mark)); } /* memset(mark, 0, sizeof(mark)); for (int i = 0; i < n; i++) { if (matchdw[i] == -1) { getCmp(i); } }*/ for (int i = 0; i < n; i++) { if (mark[i]) cout << "Mirko\n"; else cout << "Slavko\n"; } return 0; }
#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...