Submission #140293

# Submission time Handle Problem Language Result Execution time Memory
140293 2019-08-02T13:34:43 Z abacaba Planinarenje (COCI18_planinarenje) C++14
160 / 160
5 ms 1016 KB
#include <bits/stdc++.h>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

const int inf = 2e9;
const int N = 1e4 + 15;
int n, m, mt[N];
vector <int> g[N];
bool used[N];

bool kuhn(int v) {
    if(used[v])
        return false;
    used[v] = true;
    for(int to : g[v])
        if(!mt[to]) {
            mt[to] = v;
            mt[v] = to;
            return true;
        }
    for(int to : g[v])
        if(kuhn(mt[to])) {
            mt[to] = v, mt[v] = to;
            return true;
        }
    return false;
}

void dfs(int v) {
    used[v] = true;
    for(int to : g[v])
        if(!used[mt[to]])
            dfs(mt[to]);
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v + n);
        g[v + n].pb(u);
    }
    for(int run = 1; run; ) {
        run = 0, memset(used, 0, sizeof(used));
        for(int i = 1; i <= n; ++i)
            if(!mt[i] && kuhn(i))
                run = true;
    }
    memset(used, 0, sizeof(used));
    for(int i = 1; i <= n; ++i)
        if(!mt[i] && !used[i])
            dfs(i);
    for(int i = 1; i <= n; ++i) {
        if(used[i])
            puts("Mirko");
        else
            puts("Slavko");
    }
    return 0;
}

Compilation message

planinarenje.cpp: In function 'int main()':
planinarenje.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
planinarenje.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 888 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Correct 5 ms 888 KB Output is correct
4 Correct 5 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 644 KB Output is correct
2 Correct 4 ms 776 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 680 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 4 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 888 KB Output is correct
2 Correct 3 ms 760 KB Output is correct
3 Correct 5 ms 888 KB Output is correct
4 Correct 4 ms 740 KB Output is correct