Submission #140260

# Submission time Handle Problem Language Result Execution time Memory
140260 2019-08-02T11:38:51 Z abacaba Planinarenje (COCI18_planinarenje) C++14
32 / 160
306 ms 956 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 N = 1e4 + 15;
int n, m, dp[N];
vector <int> g[N];
bool used[N];

// 1 = <= n, win, Mirko
// 2 = > n, win, Slavko

void dfs(int v) {
    used[v] = true;
    for(int to : g[v]) {
        if(!used[to]) {
            dfs(to);
            if(v > n) {
                if(dp[to] == 1)
                    dp[v] = 1;
                else if(!dp[v])
                    dp[v] = 2;
            }
            else {
                if(dp[to] == 2)
                    dp[v] = 2;
                else if(!dp[v])
                    dp[v] = 1;
            }
        }
    }
    if(!dp[v])
        dp[v] = (v <= n ? 1 : 2);
}

int main() {
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v + n);
        g[v + n].pb(u);
    }
    for(int i = 1; i <= n; ++i) {
        memset(used, 0, sizeof(used));
        memset(dp, 0, sizeof(dp));
        dfs(i);
        if(dp[i] == 1)
            puts("Mirko");
        else
            puts("Slavko");
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 888 KB Output is correct
2 Correct 21 ms 956 KB Output is correct
3 Correct 19 ms 888 KB Output is correct
4 Correct 21 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 192 ms 832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 306 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 250 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -