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 <iostream>
#include <vector>
using namespace std;
const int N = 5005;
vector <int> adj[N];
bool mark[N];
int mt1[N];
int mt2[N];
bool dfs(int v) {
mark[v] = true;
for (auto u : adj[v]) {
if (!mt2[u] || (!mark[mt2[u]] && dfs(mt2[u]))) {
mt2[u] = v;
mt1[v] = u;
return true;
}
}
return false;
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
}
bool b = true;
while (b) {
fill(mark, mark + n + 1, false);
b = false;
for (int i = 1; i <= n; i++) {
if (!mt1[i] && !mark[i] && dfs(i)) {
b = true;
}
}
// cout << 47 << endl;
}
/* cout << 48 << endl;
for (int i = 1; i <= n; i++) {
cout << "49 " << i << " " << mt1[i] << endl;
}*/
for (int i = 1; i <= n; i++) {
if (!mt1[i]) {
cout << "Mirko" << endl;
}
else {
fill(mark, mark + n + 1, false);
bool b = false;
mt2[mt1[i]] = 0;
for (int j = 1; j <= n; j++) {
if (j != i && !mark[j] && !mt1[j] && dfs(j)) {
b = true;
}
}
if (b) {
mt1[i] = 0;
cout << "Mirko" << endl;
}
else {
mt2[mt1[i]] = i;
cout << "Slavko" << endl;
}
}
}
return 0;
}
# | 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... |