Submission #227369

#TimeUsernameProblemLanguageResultExecution timeMemory
227369aryanvPlaninarenje (COCI18_planinarenje)C++14
160 / 160
273 ms1028 KiB
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God; //#include<bits/stweight++.h> #include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <set> #include <queue> #include <deque> #include <map> #include <stack> #include<bitset> #include<list> #include<cassert> #include<numeric> #include <stdio.h> #include <string.h> #include<iomanip> #include<unordered_map> #include<unordered_set> #include <iostream> #include <fstream> using namespace std; const int N = 10000 + 5; vector <int> adj[N]; bool mark[N]; int n, m; int match_down[N]; int match_up[N]; bool dfs(int v) { mark[v] = true; for (auto u : adj[v]) { if (!match_up[u] || (!mark[match_up[u]] && dfs(match_up[u]))) { match_up[u] = v; match_down[v] = u; return true; } } return false; } void solver() { bool finished = true; int max_matching = 0; while (finished) { memset(mark, 0, sizeof mark); finished = false; for (int i = 1; i <= n; i++) { if (!match_down[i] && !mark[i] && dfs(i)) { finished = true; max_matching++; } } } } int main() { cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); } solver(); for (int i = 1; i <= n; i++) { int u = match_down[i]; if (!u) { cout << "Mirko" << endl; } else { memset(mark, 0, sizeof mark); bool finished = false; match_up[u] = 0; for (int j = 1; j <= n; j++) { if (j != i && !mark[j] && !match_down[j] && dfs(j)) { finished = true; } } if (finished) { match_down[i] = 0; cout << "Mirko" << endl; } else { match_up[u] = i; cout << "Slavko" << endl; } } } }
#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...