Submission #233096

#TimeUsernameProblemLanguageResultExecution timeMemory
233096HeydarBABAPlaninarenje (COCI18_planinarenje)C++14
160 / 160
29 ms896 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 5e3 + 10; int n, m; int par[maxn]; bool mark[maxn]; string ans[maxn]; vector<int> adj[maxn]; void in(); void solve(); bool can(int); void out(); int main(){ ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); in(); solve(); out(); } void in(){ cin >> n >> m; for(int i = 0; i < m; i++){ int u, v; cin >> u >> v; u--; v--; adj[v].push_back(u); } } void solve(){ memset(par, -1, sizeof par); for(int i = 0; i < n; i++){ can(i); memset(mark, 0, sizeof mark); } for(int i = 0; i < n; i++){ ans[i] = "Slavko\n"; if(par[i] == -1) ans[i] = "Mirko\n"; else{ memset(mark, 0, sizeof mark); mark[i] = 1; if(can(par[i])){ par[i] = -1; ans[i] = "Mirko\n"; } } } } bool can(int u){ for(auto v: adj[u]){ if(!mark[v]){ mark[v] = 1; if(par[v] == -1 || can(par[v])){ par[v] = u; return 1; } } } return 0; } void out(){ for(int i = 0; i < n; i++) cout << ans[i]; }
#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...