#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
int n, m;
int par[maxn];
bool mark[maxn];
string ans[maxn];
vector<int> adj[maxn];
void in();
void solve();
bool can(int);
void out();
int main(){
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
in();
solve();
out();
}
void in(){
cin >> n >> m;
for(int i = 0; i < m; i++){
int u, v;
cin >> u >> v;
u--;
v--;
adj[v].push_back(u);
}
}
void solve(){
memset(par, -1, sizeof par);
for(int i = 0; i < n; i++){
can(i);
memset(mark, 0, sizeof mark);
}
for(int i = 0; i < n; i++){
ans[i] = "Slavko\n";
if(par[i] == -1)
ans[i] = "Mirko\n";
else{
memset(mark, 0, sizeof mark);
mark[i] = 1;
if(can(par[i])){
par[i] = -1;
ans[i] = "Mirko\n";
}
}
}
}
bool can(int u){
for(auto v: adj[u]){
if(!mark[v]){
mark[v] = 1;
if(par[v] == -1 || can(par[v])){
par[v] = u;
return 1;
}
}
}
return 0;
}
void out(){
for(int i = 0; i < n; i++)
cout << ans[i];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
768 KB |
Output is correct |
3 |
Correct |
8 ms |
768 KB |
Output is correct |
4 |
Correct |
8 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
640 KB |
Output is correct |
2 |
Correct |
15 ms |
768 KB |
Output is correct |
3 |
Correct |
9 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
640 KB |
Output is correct |
2 |
Correct |
7 ms |
640 KB |
Output is correct |
3 |
Correct |
11 ms |
640 KB |
Output is correct |
4 |
Correct |
14 ms |
820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
896 KB |
Output is correct |
3 |
Correct |
8 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
768 KB |
Output is correct |
3 |
Correct |
6 ms |
768 KB |
Output is correct |
4 |
Correct |
29 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
768 KB |
Output is correct |
2 |
Correct |
6 ms |
768 KB |
Output is correct |
3 |
Correct |
7 ms |
768 KB |
Output is correct |
4 |
Correct |
15 ms |
768 KB |
Output is correct |