#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'
vector<vi> adj;
vi match;
bool augmentingPath(int l, int r) {
// l and r are the number of nodes on left and right side.
// It will be assumed that nodes 0 -> l-1 are the ones on the left side and rest l -> l+r-1 on the right
vi pre(l+r, -1);
int end = -1;
queue<int> q;
for_(i, 0, l) if (match[i] == -1) {
q.push(i);
pre[i] = i;
}
while (q.size() and end == -1) {
int p = q.front(); q.pop();
bool right = p >= l;
for (int i: adj[p]) if (match[i] != -2 and ((match[p] == i) == right)) {
pre[i] = p;
// found an unmatched edge on the right side
if (match[i] == -1) {
end = i;
break;
}
q.push(i);
}
}
if (end == -1) return false; // couln't find augmenting path
// update the matching to include the flipped edges in the augmenting path
int p = end;
while (true) {
if (pre[p] == p) break;
match[p] = pre[p];
match[pre[p]] = p;
p = pre[pre[p]];
}
return 1;
}
int main() {
#ifdef shiven
freopen("test.in", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m; cin >> n >> m;
adj.resize(2*n); match.resize(2*n, -1);
for_(i, 0, m) {
int a, b; cin >> a >> b;
a -= 1; b += n-1;
adj[a].push_back(b);
adj[b].push_back(a);
}
int full = 0;
while (true) {
int v = augmentingPath(n, n);
if (!v) break;
full += v;
}
for_(i, 0, n) {
bool first = true;
if (match[i] == -1) first = false;
else {
int k = match[i];
match[k] = -1;
match[i] = -2;
if (augmentingPath(n, n)) first = false;
match[k] = i;
match[i] = k;
}
cout << (first ? "Slavko" : "Mirko") << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
362 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1090 ms |
588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1079 ms |
640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1058 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |