//besmellah
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 5;
bitset <2 * maxn> mark;
int match[maxn], M[maxn], n;
vector <int> adj[2 * maxn], g[maxn];
bool dfs(int v) {
if (mark[v])
return 0;
mark[v] = 1;
for (auto u: adj[v]) {
// cout << v << ' ' << u << ' ' << M[u - n] << endl;
if (M[u - n] == -1 || dfs(M[u - n])) {
// cout << v << ' ' << u << endl;
M[u - n] = v;
match[v] = u;
return 1;
}
}
return 0;
}
void D(int v) {
mark[v] = 1;
for (auto u: g[v]) {
if (!mark[u])
D(u);
}
}
int main() {
int m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int v, u;
cin >> v >> u;
v--;
u += n - 1;
adj[v].push_back(u);
adj[u].push_back(v);
}
fill(match, match + n, -1);
fill(M, M + n, -1);
for (int i = 0; i < n; i++) {
if (match[i] == -1) {
mark = 0;
dfs(i);
}
}
mark = 0;
for (int i = 0; i < n; i++) {
for (auto u: adj[i]) {
if (~M[u - n]) {
g[i].push_back(M[u - n]);
}
}
}
for (int i = 0; i < n; i++) {
if (match[i] == -1 && !mark[i])
D(i);
}
for (int i = 0; i < n; i++) {
if (!mark[i])
cout << "Slavko\n";
else
cout << "Mirko\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
7 ms |
768 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
5 ms |
768 KB |
Output is correct |
4 |
Correct |
5 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
1280 KB |
Output is correct |
2 |
Correct |
10 ms |
1280 KB |
Output is correct |
3 |
Correct |
10 ms |
1152 KB |
Output is correct |
4 |
Correct |
11 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
768 KB |
Output is correct |
2 |
Correct |
9 ms |
896 KB |
Output is correct |
3 |
Correct |
7 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
768 KB |
Output is correct |
3 |
Correct |
8 ms |
948 KB |
Output is correct |
4 |
Correct |
9 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
896 KB |
Output is correct |
2 |
Correct |
10 ms |
1152 KB |
Output is correct |
3 |
Correct |
9 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
896 KB |
Output is correct |
2 |
Correct |
10 ms |
1024 KB |
Output is correct |
3 |
Correct |
7 ms |
896 KB |
Output is correct |
4 |
Correct |
10 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
1024 KB |
Output is correct |
2 |
Correct |
7 ms |
896 KB |
Output is correct |
3 |
Correct |
10 ms |
1024 KB |
Output is correct |
4 |
Correct |
11 ms |
896 KB |
Output is correct |