#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
int n, m, mat[maxn];
vector<int> adj[maxn];
bitset<maxn> mark, fmat, ans;
bool dfs(int v){
if (mark[v]) return false;
mark[v] = true;
for (auto u:adj[v])
if (mat[u] == -1 || dfs(mat[u])){
if (mat[u] != -1)
ans[mat[u]] = true;
mat[u] = v;
return true;
}
return false;
}
void dfs2(int v){
if (mark[v]) return;
mark[v] = true;
for (auto u:adj[v])
if (mat[u] != -1){
ans[mat[u]] = true;
dfs2(mat[u]);
}
return;
}
int main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
memset(mat, -1, sizeof(mat));
cin >> n >> m;
for (int i = 0, v, u; i < m; i++){
cin >> v >> u; v--, u--;
adj[v].push_back(u);
}
bool find = true;
while (find){
find = false;
mark.reset();
for (int i = 0; i < n; i++)
if (!fmat[i] && dfs(i))
fmat[i] = find = true;
}
mark.reset();
ans.reset();
for (int i = 0; i < n; i++)
if (!fmat[i])
dfs2(i);
for (int i = 0; i < n; i++)
if (!fmat[i] || ans[i])
cout << "Mirko\n";
else
cout << "Slavko\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
588 KB |
Output is correct |
2 |
Correct |
4 ms |
720 KB |
Output is correct |
3 |
Correct |
4 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
588 KB |
Output is correct |
2 |
Correct |
4 ms |
596 KB |
Output is correct |
3 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
460 KB |
Output is correct |
2 |
Correct |
4 ms |
568 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
592 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
4 ms |
460 KB |
Output is correct |