//
// fstmm.cpp
// Code
//
// Created by Mohammadreza Raddanipour on 12/23/19.
// Copyright © 2019 Mohammadreza Raddanipour. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;
const int MXN = 5e3 + 20;
int n, m, mch[MXN];
vector<int> adj[MXN];
bool mchd[MXN], vs[MXN];
void npt() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
adj[--u].push_back(--v);
}
}
bool dfs(int v) {
vs[v] = 1;
for (auto u: adj[v])
if (mch[u] == -1 || (!vs[mch[u]] && dfs(mch[u]))) {
mch[u] = v;
mchd[v] = 1;
return 1;
}
return 0;
}
void mm() {
for (bool flg = 1; flg; memset(vs, 0, sizeof vs)) {
flg = 0;
for (int i = 0; i < n; i++)
if (!vs[i] && !mchd[i])
flg |= dfs(i);
}
}
int main() {
memset(mch, -1, sizeof mch);
npt();
mm();
for (int i = 0; i < n; i++)
if (!vs[i])
cout << "Slavko\n";
else
cout << "Mirko\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |