#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
vector<int> adj[MAXN];
bool vis[MAXN], matched[MAXN], flip[MAXN];
int match[MAXN];
bool aug(int x){
if (vis[x]) return 0;
vis[x] = 1;
for (int nxt : adj[x])
if (match[nxt] == -1 || aug(match[nxt])){
match[nxt] = x;
return 1;
}
return 0;
}
bool alt(int x){
if (vis[x]) return 0;
vis[x] = 1;
for (int nxt : adj[x]){
if (match[nxt] != -1){
flip[match[nxt]] = 1;
alt(match[nxt]);
}
}
return 0;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int nums, edges; cin >> nums >> edges;
for (int i = 0; i < edges; i++){
int p, v; cin >> p >> v;
adj[p].push_back(v);
}
for (int i = 1; i <= nums; i++) match[i] = -1;
for (int i = 1; i <= nums; i++){
for (int j = 1; j <= nums; j++) vis[j] = 0;
aug(i);
}
for (int i = 1; i <= nums; i++)
if (match[i] != -1)
matched[match[i]] = 1;
for (int i = 1; i <= nums; i++)
if (!matched[i]){
for (int j = 1; j <= nums; j++) vis[j] = 0;
alt(i);
}
for (int i = 1; i <= nums; i++){
if (!matched[i] || flip[i]) cout << "Mirko\n";
else cout << "Slavko\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Output is correct |
2 |
Correct |
2 ms |
596 KB |
Output is correct |
3 |
Correct |
2 ms |
596 KB |
Output is correct |
4 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |