Submission #237568

# Submission time Handle Problem Language Result Execution time Memory
237568 2020-06-07T11:08:28 Z VEGAnn Planinarenje (COCI18_planinarenje) C++14
160 / 160
55 ms 1016 KB
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 10010;
const int PW = (1 << 20);
vector<int> g[N];
int n, m, mt[N];
bool used[N];

bool try_kuhn(int v){
    if (used[v]) return 0;

    used[v] = 1;

    for (int u : g[v])
        if (mt[u] == -1 || try_kuhn(mt[u])){
            mt[u] = v;
            return 1;
        }

    return 0;
}

bool good(int v){
    if (used[v]) return 0;

    used[v] = 1;

    for (int u : g[v])
        if (mt[u] == -1 || good(mt[u]))
            return 1;

    return 0;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m;

    for (int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        x--; y--; y += n;

        g[x].PB(y);
        g[y].PB(x);
    }

    fill(mt, mt + n + n, -1);

    for (int v = 0; v < n; v++){
        fill(used, used + n + n, 0);

        try_kuhn(v);
    }

    for (int v = n; v < n + n; v++)
        if (mt[v] >= 0)
            mt[mt[v]] = v;

    for (int v = 0; v < n; v++)
        if (mt[v] < 0)
            cout << "Mirko\n";
        else {
            fill(used, used + n + n, 0);

            cout << (good(mt[v]) ? "Mirko\n" : "Slavko\n");
        }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 896 KB Output is correct
2 Correct 46 ms 896 KB Output is correct
3 Correct 55 ms 896 KB Output is correct
4 Correct 44 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 640 KB Output is correct
2 Correct 19 ms 768 KB Output is correct
3 Correct 14 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 640 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 14 ms 768 KB Output is correct
4 Correct 16 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 768 KB Output is correct
2 Correct 45 ms 896 KB Output is correct
3 Correct 16 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 768 KB Output is correct
2 Correct 29 ms 932 KB Output is correct
3 Correct 13 ms 768 KB Output is correct
4 Correct 37 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 768 KB Output is correct
2 Correct 13 ms 896 KB Output is correct
3 Correct 24 ms 896 KB Output is correct
4 Correct 27 ms 768 KB Output is correct