답안 #317368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
317368 2020-10-29T15:53:59 Z mohamedsobhi777 낙하산 고리들 (IOI12_rings) C++14
0 / 100
42 ms 1024 KB
#include <bits/stdc++.h>

using namespace std;
int N;
const int cn = 10000;

vector<int> adj[cn];
int deg[cn];
int vis[cn];
int c;
bool bd = 1;
int del;

void dfs(int x, int p)
{
        vis[x] = c;
        for (auto u : adj[x])
        {
                if (u == p || del == u)
                        continue;
                if (vis[u] == c)
                        bd = 0;
                else
                        dfs(u, x);
        }
}

int brute()
{
        ++c;
        set<int> cri;
        for (int i = 0; i < N; ++i)
        {
                del = i;
                for (auto u : adj[i])
                {
                        deg[u]--;
                        deg[i]--;
                }
                bool ok = 1;
                for (int j = 0; j < N; ++j)
                {
                        if (deg[j] > 2)
                                ok = 0;
                        if (vis[i] != c && i != j)
                        {
                                bd = 1;
                                dfs(i, i);
                                ok &= bd;
                        }
                }
                if (ok)
                        cri.insert(i);
                for (auto u : adj[i])
                {
                        deg[u]++;
                        deg[i]++;
                }
        }
        return (int)cri.size();
}

void Init(int N_)
{

        N = N_;
}

void Link(int A, int B)
{
        adj[A].push_back(B);
        adj[B].push_back(A);
        deg[A]++;
        deg[B]++;
}

int CountCritical()
{
        return brute();
        return N;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 29 ms 768 KB Output is correct
3 Correct 42 ms 768 KB Output is correct
4 Incorrect 3 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 29 ms 768 KB Output is correct
3 Correct 42 ms 768 KB Output is correct
4 Incorrect 3 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 29 ms 768 KB Output is correct
3 Correct 42 ms 768 KB Output is correct
4 Incorrect 3 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 29 ms 768 KB Output is correct
3 Correct 42 ms 768 KB Output is correct
4 Incorrect 3 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -