#include <bits/stdc++.h>
using namespace std;
#define dbg(x) cerr << #x << ": " << x << endl;
const int MAX_N = 5000 + 5;
vector<int> g[MAX_N];
int used[MAX_N];
int match[MAX_N];
int timer = 1;
bool dfs(int v) {
if (used[v] == timer) {
return false;
}
used[v] = timer;
for (auto u : g[v]) {
if (match[u] == -1) {
match[u] = v;
return true;
}
}
for (auto u : g[v]) {
if (dfs(match[u])) {
match[u] = v;
return true;
}
}
return false;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
--u, --v;
g[u].push_back(v);
}
memset(match, -1, sizeof(match));
int cnt = 0;
vector<int> covered;
for (int v = 0; v < n; ++v) {
if (dfs(v)) {
++timer;
++cnt;
}
}
for (int i = 0; i < n; ++i) {
int curr = 0;
memset(match, -1, sizeof(match));
++timer;
for (int v = 0; v < n; ++v) {
if (v == i) continue;
if (dfs(v)) {
++timer;
++curr;
}
}
if (curr < cnt) {
cout << "Slavko\n";
} else {
cout << "Mirko\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
608 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
306 ms |
780 KB |
Output is correct |
2 |
Correct |
270 ms |
928 KB |
Output is correct |
3 |
Correct |
215 ms |
600 KB |
Output is correct |
4 |
Correct |
264 ms |
776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
103 ms |
612 KB |
Output is correct |
2 |
Correct |
4 ms |
600 KB |
Output is correct |
3 |
Correct |
16 ms |
800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
600 KB |
Output is correct |
2 |
Correct |
144 ms |
608 KB |
Output is correct |
3 |
Correct |
33 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
490 ms |
648 KB |
Output is correct |
2 |
Correct |
145 ms |
696 KB |
Output is correct |
3 |
Correct |
58 ms |
604 KB |
Output is correct |
4 |
Correct |
40 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
604 KB |
Output is correct |
2 |
Correct |
70 ms |
676 KB |
Output is correct |
3 |
Correct |
126 ms |
684 KB |
Output is correct |
4 |
Correct |
330 ms |
856 KB |
Output is correct |