Submission #42857

#TimeUsernameProblemLanguageResultExecution timeMemory
42857MAMBAPlaninarenje (COCI18_planinarenje)C++14
160 / 160
5 ms1740 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; const int MAXN = 1e4 + 10; int n, m, k, pair_[MAXN << 1]; vector<int> adj[MAXN << 1]; bool mark[MAXN << 1], match[MAXN << 1]; bool answer[MAXN << 1]; bool dfs(int v) { mark[v] = true; for (auto i : adj[v]) if (!match[i] || (!mark[pair_[i]] && dfs(pair_[i]))) { match[v] = match[i] = true; pair_[v] = i; pair_[i] = v; return true; } return false; } void dfs_(int v) { mark[v] = true; for (auto i : adj[v]) { if (match[i] && !mark[pair_[i]]) { answer[pair_[i]] = false; dfs_(pair_[i]); } } } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> k; m = n; for (int i = 0; i < k; i++) { int u, v; cin >> u >> v; v += n; adj[u].push_back(v); adj[v].push_back(u); } while (true) { bool lf = false; memset(mark, 0, sizeof(mark)); for (int i = 1; i <= n; i++) if (!match[i] && dfs(i)) { lf = true; } if (!lf) break; } memset(mark, 0, sizeof(mark)); for (int i = 1; i <= n + m; i++) if (match[i]) answer[i] = true; for (int i = 1; i <= n + m; i++) { if (match[i] || mark[i]) continue; dfs_(i); } for (int i = 1; i <= n; i++) { if (answer[i]) cout << "Slavko" << '\n'; else cout << "Mirko" << '\n'; } //cin >> 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...