Submission #119771

# Submission time Handle Problem Language Result Execution time Memory
119771 2019-06-22T09:04:54 Z ahmad_salah Parachute rings (IOI12_rings) C++17
0 / 100
4000 ms 42572 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 1e6;
int n;
vector<int> adj[M];
bool v[M], ok;

void dfs(int node, bool bef, int forb) {
    if (!v[node]) {
        v[node] = 1;

        int cnt = 0;
        for (int x : adj[node])
            if (x != forb)
                cnt++;

        if ((!bef && cnt > 2) || (bef && cnt > 1)) {
            ok = false;
            return;
        }

        for (int x : adj[node])
            if (x != forb)
                dfs(x, 1, forb);
    }
}

void Init(int N) { n = N; }

void Link(int a, int b) {
    adj[a].push_back(b);
    adj[b].push_back(a);
}

int CountCritical() {
    int ans = 0;

    for (int i = 0; i < n; i++) {
        memset(v, 0, sizeof v);
        ok = true;

        for (int j = 0; j < n; j++)
            if (!v[j] && i != j)
                dfs(j, 0, i);
        if (ok)
            ans++;
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 24824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4019 ms 42572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 24824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 24824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 24824 KB Output isn't correct
2 Halted 0 ms 0 KB -