Submission #330656

# Submission time Handle Problem Language Result Execution time Memory
330656 2020-11-26T05:18:41 Z caoash Planinarenje (COCI18_planinarenje) C++17
0 / 160
317 ms 1036 KB
#include <bits/stdc++.h> 
using namespace std;

using ll = long long;

using vi = vector<int>;
using vl = vector<ll>;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

const int MX = 5005;
const int MOD = (int) (1e9 + 7);
const ll INF = (ll) 1e18;

int done[MX];
int pa[MX], pb[MX];
int it = 0;
vi adj[MX];

bool dfs(int v) {
    done[v] = it;
    for (int to : adj[v]) {
        if (pb[to] == -1) {
            pa[v] = to;
            pb[to] = v;
            return true;
        }
    }
    for (int to : adj[v]) {
        if (done[pb[to]] != it && dfs(pb[to])) {
            pa[v] = to;
            pb[to] = v;
            return true;
        }
    }
    return false;
}

int main(){
#ifdef mikey 
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;    
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
    }
    memset(pa, -1, sizeof(pa));
    memset(pb, -1, sizeof(pb));
    auto aug = [&] () {
        int mm = 0;
        for (int i = 0; i < n; i++) {
            if (pa[i] == -1 && dfs(i)) ++mm;    
        }
        return mm;
    };
    int best = 0;
    int add = 0;
    do {
        add = aug();
        best += add;
    } while (add > 0);
    for (int i = 0; i < n; i++) {
        int nbest = best - 1;
        int old = pa[i];
        pa[i] = -1, pb[old] = -1;
        do {
            add = aug();
            nbest += add;
        } while (add > 0);
        assert(nbest <= best);
        if (nbest == best) {
            cout << "Slavko\n";
        } else {
            cout << "Mirko\n";
        }
        pa[i] = old, pb[old] = i;
    }
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Incorrect 1 ms 492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 317 ms 1036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -