답안 #912121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912121 2024-01-19T07:42:41 Z teo_thrash Planinarenje (COCI18_planinarenje) C++14
160 / 160
29 ms 1084 KB
// 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;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 860 KB Output is correct
2 Correct 10 ms 1084 KB Output is correct
3 Correct 8 ms 860 KB Output is correct
4 Correct 8 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 604 KB Output is correct
2 Correct 13 ms 860 KB Output is correct
3 Correct 8 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 9 ms 836 KB Output is correct
4 Correct 9 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 860 KB Output is correct
2 Correct 8 ms 1008 KB Output is correct
3 Correct 7 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 860 KB Output is correct
2 Correct 10 ms 860 KB Output is correct
3 Correct 6 ms 892 KB Output is correct
4 Correct 29 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 860 KB Output is correct
2 Correct 5 ms 860 KB Output is correct
3 Correct 7 ms 860 KB Output is correct
4 Correct 10 ms 928 KB Output is correct