Submission #228251

#TimeUsernameProblemLanguageResultExecution timeMemory
228251shengdebaoPlaninarenje (COCI18_planinarenje)C++14
160 / 160
270 ms912 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] == -1 || (!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 = 0; i < n; i++) { if (match_down[i] == -1 && !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 - 1].push_back(v - 1); } memset(match_down, -1, sizeof match_down); memset(match_up, -1, sizeof match_up); solver(); //cout << max_matching for (int i = 0; i < n; i++) { int u = match_down[i]; //cout << i << " " << u << endl; //exit(0); if (u == -1) { cout << "Mirko" << endl; } else { memset(mark, 0, sizeof mark); bool finished = false; match_up[u] = -1; for (int j = 0; j < n; j++) { if (j != i && !mark[j] && match_down[j] == -1 && dfs(j)) { finished = true; } } if (finished) { match_down[i] = -1; 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...