This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
vector<int> adj[MAXN];
bool vis[MAXN];
int match[MAXN];
bool aug(int x){
if (vis[x]) return 0;
vis[x] = 1;
for (int nxt : adj[x])
if (match[nxt] == -1 || aug(match[nxt])){
match[nxt] = x; match[x] = nxt;
return 1;
}
return 0;
}
bool alt(int x){
if (vis[x]) return 0;
vis[x] = 1;
for (int nxt : adj[x]){
if (match[nxt] == -1 || alt(match[nxt]))
return 1;
}
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int nums, nodes, edges; cin >> nums >> edges;
nodes = 2 * nums;
for (int i = 0; i < edges; i++){
int p, v; cin >> p >> v; v += nums;
adj[p].push_back(v);
adj[v].push_back(p);
}
for (int i = 1; i <= nodes; i++) match[i] = -1;
for (int i = 1; i <= nodes; i++)
if (match[i] == -1){
for (int j = 1; j <= nodes; j++) vis[j] = 0;
aug(i);
}
for (int i = 1; i <= nums; i++){
if (match[i] == -1) cout << "Mirko\n";
else{
for (int j = 1; j <= nodes; j++) vis[j] = 0;
cout << (alt(match[i]) ? "Mirko" : "Slavko") << '\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |