답안 #169984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169984 2019-12-23T13:58:43 Z darklight256 Planinarenje (COCI18_planinarenje) C++14
160 / 160
12 ms 760 KB
//
//  pl.cpp
//  Code
//
//  Created by Mohammadreza Raddanipour on 12/23/19.
//  Copyright © 2019 Mohammadreza Raddanipour. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

const int MXN = 5e3 + 20;

vector<int> adj[MXN];
int mch[MXN], n, m;
bool vs[MXN], mchd[MXN], wn[MXN];

void npt() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[--u].push_back(--v);
    }
}

bool dfs(int v) {
    vs[v] = 1;
    for (auto u: adj[v])
        if (mch[u] == -1 || (!vs[mch[u]] && dfs(mch[u]))) {
            mch[u] = v;
            mchd[v] = 1;
            return 1;
        }
    return 0;
}

void mm() {
    for (int i = 0; i < n; i++) {
        memset(vs, 0, sizeof vs);
        dfs(i);
    }
}

void slv() {
    memset(vs, 0, sizeof vs);
    for (int i = 0; i < n;  i++)
        if (!mchd[i])
            dfs(i);
    for (int i = 0; i < n; i++)
        if (!vs[i])
            cout << "Slavko\n";
        else
            cout << "Mirko\n";
}

int main() {
    memset(mch, -1, sizeof mch);
    npt();
    mm();
    slv();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 636 KB Output is correct
2 Correct 8 ms 760 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
4 Correct 8 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 632 KB Output is correct
2 Correct 8 ms 632 KB Output is correct
3 Correct 8 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 632 KB Output is correct
2 Correct 8 ms 632 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 632 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 7 ms 632 KB Output is correct
4 Correct 9 ms 604 KB Output is correct