This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// it is your desire to work hard
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn=1e4+3;
const int mod=1e9+7;
int n, m;
vector<int> nbrs[maxn];
bool used[maxn];
int to[maxn];
bool non_active[maxn];
bool dfs(int x){
if(used[x]) return false;
used[x]=true;
for(auto v: nbrs[x]){
if(non_active[v]) continue;
if(to[v]==-1 or dfs(to[v])){
to[v]=x;
return true;
}
}
return false;
}
bool augment(int x){
for(int i=0; i<maxn; i++){
used[i]=false;
}
return dfs(x);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
for(int i=0; i<m; i++){
int a, b;
cin>>a>>b;
b+=n;
nbrs[a].pb(b);
nbrs[b].pb(a);
}
for(int i=0; i<maxn; i++){
to[i]=-1;
used[i]=false;
}
for(int i=n+1; i<=2*n; i++){
if(to[i]==-1){
augment(i);
}
}
for(int i=1; i<=n; i++){
if(to[i]==-1){
cout<<"Mirko"<<endl;
continue;
}
int temp=to[i];
to[i]=-1;
non_active[i]=true;
if(augment(temp)){
non_active[i]=false;
cout<<"Mirko"<<endl;
}else{
non_active[i]=false;
augment(temp);
cout<<"Slavko"<<endl;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |