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 MN = 50012;
vector <int> adj[MN], kaj[MN];
int p[MN], good[MN];
bool mark[MN];
bool dfs(int v) {
mark[v] = true;
for (int u: adj[v])
if ((p[u] == -1) || (!mark[p[u]] && dfs(p[u]))) {
p[u] = v;
return true;
}
return false;
}
bool sms(int v) {
mark[v] = true;
for (int u: kaj[v])
if ((good[u] == -1) || (!mark[good[u]] && sms(good[u])))
return true;
return false;
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
good[i] = p[i] = -1;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
adj[--a].push_back(--b);
kaj[b].push_back(a);
}
for (int i = 0; i < n; i++) {
for (int i = 0; i < n; i++)
mark[i] = false;
dfs(i);
}
for (int i = 0; i < n; i++)
if (p[i] != -1)
good[p[i]] = i;
for (int i = 0; i < n; i++) {
for (int i = 0; i < n; i++)
mark[i] = false;
if (good[i] == -1)
cout << "Mirko\n";
else if (sms(good[i]))
cout << "Mirko\n";
else
cout << "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... |