Submission #232961

#TimeUsernameProblemLanguageResultExecution timeMemory
232961smhh22Planinarenje (COCI18_planinarenje)C++11
160 / 160
18 ms1280 KiB
//besmellah #include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5; bitset <2 * maxn> mark; int match[maxn], M[maxn], n; vector <int> adj[2 * maxn], g[maxn]; bool dfs(int v) { if (mark[v]) return 0; mark[v] = 1; for (auto u: adj[v]) { // cout << v << ' ' << u << ' ' << M[u - n] << endl; if (M[u - n] == -1 || dfs(M[u - n])) { // cout << v << ' ' << u << endl; M[u - n] = v; match[v] = u; return 1; } } return 0; } void D(int v) { mark[v] = 1; for (auto u: g[v]) { if (!mark[u]) D(u); } } int main() { int m; cin >> n >> m; for (int i = 0; i < m; i++) { int v, u; cin >> v >> u; v--; u += n - 1; adj[v].push_back(u); adj[u].push_back(v); } fill(match, match + n, -1); fill(M, M + n, -1); for (int i = 0; i < n; i++) { if (match[i] == -1) { mark = 0; dfs(i); } } mark = 0; for (int i = 0; i < n; i++) { for (auto u: adj[i]) { if (~M[u - n]) { g[i].push_back(M[u - n]); } } } for (int i = 0; i < n; i++) { if (match[i] == -1 && !mark[i]) D(i); } for (int i = 0; i < n; i++) { if (!mark[i]) cout << "Slavko\n"; else cout << "Mirko\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...