#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 |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
512 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
512 KB |
Output is correct |
4 |
Correct |
8 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
640 KB |
Output is correct |
2 |
Correct |
276 ms |
640 KB |
Output is correct |
3 |
Correct |
244 ms |
640 KB |
Output is correct |
4 |
Correct |
276 ms |
808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
512 KB |
Output is correct |
2 |
Correct |
9 ms |
512 KB |
Output is correct |
3 |
Correct |
9 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
512 KB |
Output is correct |
2 |
Correct |
21 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
512 KB |
Output is correct |
4 |
Correct |
9 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
512 KB |
Output is correct |
2 |
Correct |
166 ms |
640 KB |
Output is correct |
3 |
Correct |
63 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
512 KB |
Output is correct |
2 |
Correct |
116 ms |
760 KB |
Output is correct |
3 |
Correct |
62 ms |
512 KB |
Output is correct |
4 |
Correct |
11 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
512 KB |
Output is correct |
2 |
Correct |
67 ms |
640 KB |
Output is correct |
3 |
Correct |
121 ms |
632 KB |
Output is correct |
4 |
Correct |
30 ms |
512 KB |
Output is correct |