#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 5e4+10;
bool mark[maxn], fmatch[maxn], tmp[maxn];
vector<int> adj[maxn];
int match[maxn];
bool dfs(int v){
if(mark[v]) return false;
mark[v] = true;
for(int u: adj[v])
if(match[u] == -1 || dfs(match[u])){
match[u] = v;
return true;
}
return false;
}
void dfs2(int v){
if(mark[v]) return;
mark[v] = true;
for(int u: adj[v])
if(match[u] != -1){
tmp[match[u]] = false;
dfs2(match[u]);
}
}
int main(){
memset(match, -1, sizeof(match));
int n, m;
cin >> n >> m;
for(int i = 0, u, v; i < m; i++){
cin >> u >> v; u--; v--;
adj[u].pb(v);
}
bool find = true;
while(find){
find = false;
memset(mark, 0, sizeof(mark));
for(int i = 0; i < n; i++)
if(!fmatch[i] && dfs(i)){
find = true;
fmatch[i] = true;
}
}
memset(mark, 0, sizeof(mark));
memset(tmp, 1, sizeof(tmp));
for(int i = 0; i < n; i++)
if(!fmatch[i])
dfs2(i);
for(int i = 0; i < n; i++)
if(!fmatch[i] || !tmp[i])
cout << "Mirko\n";
else
cout << "Slavko\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1740 KB |
Output is correct |
2 |
Correct |
2 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1740 KB |
Output is correct |
2 |
Correct |
2 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1740 KB |
Output is correct |
2 |
Correct |
2 ms |
1740 KB |
Output is correct |
3 |
Correct |
2 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1740 KB |
Output is correct |
2 |
Correct |
2 ms |
1740 KB |
Output is correct |
3 |
Correct |
2 ms |
1740 KB |
Output is correct |
4 |
Correct |
2 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1908 KB |
Output is correct |
2 |
Correct |
6 ms |
1868 KB |
Output is correct |
3 |
Correct |
4 ms |
1868 KB |
Output is correct |
4 |
Correct |
6 ms |
1992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1740 KB |
Output is correct |
2 |
Correct |
5 ms |
1808 KB |
Output is correct |
3 |
Correct |
4 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1740 KB |
Output is correct |
2 |
Correct |
3 ms |
1740 KB |
Output is correct |
3 |
Correct |
3 ms |
1740 KB |
Output is correct |
4 |
Correct |
5 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1740 KB |
Output is correct |
2 |
Correct |
6 ms |
1868 KB |
Output is correct |
3 |
Correct |
5 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1828 KB |
Output is correct |
2 |
Correct |
5 ms |
1868 KB |
Output is correct |
3 |
Correct |
3 ms |
1868 KB |
Output is correct |
4 |
Correct |
5 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1740 KB |
Output is correct |
2 |
Correct |
4 ms |
1868 KB |
Output is correct |
3 |
Correct |
5 ms |
1868 KB |
Output is correct |
4 |
Correct |
6 ms |
1868 KB |
Output is correct |