#include <bits/stdc++.h>
using namespace std;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
const int N = 1e4 + 15;
int n, m, dp[N];
vector <int> g[N];
bool used[N];
// 1 = <= n, win, Mirko
// 2 = > n, win, Slavko
void dfs(int v, int p = -1) {
used[v] = true;
for(int to : g[v]) {
if(!used[to])
dfs(to, v);
if(to != p) {
if(v > n) {
if(dp[to] == 1)
dp[v] = 1;
else if(!dp[v])
dp[v] = 2;
}
else {
if(dp[to] == 2)
dp[v] = 2;
else if(!dp[v])
dp[v] = 1;
}
}
}
if(!dp[v])
dp[v] = (v <= n ? 1 : 2);
}
int main() {
cin >> n >> m;
for(int i = 1; i <= m; ++i) {
int u, v;
cin >> u >> v;
g[u].pb(v + n);
g[v + n].pb(u);
}
for(int i = 1; i <= n; ++i) {
memset(used, 0, sizeof(used));
memset(dp, 0, sizeof(dp));
dfs(i);
if(dp[i] == 1)
puts("Mirko");
else
puts("Slavko");
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
632 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
632 KB |
Output is correct |
2 |
Correct |
4 ms |
632 KB |
Output is correct |
3 |
Correct |
4 ms |
632 KB |
Output is correct |
4 |
Correct |
4 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
956 KB |
Output is correct |
2 |
Correct |
20 ms |
888 KB |
Output is correct |
3 |
Correct |
17 ms |
892 KB |
Output is correct |
4 |
Correct |
20 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
258 ms |
1060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
416 ms |
992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
273 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |