답안 #317366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
317366 2020-10-29T15:51:16 Z mohamedsobhi777 낙하산 고리들 (IOI12_rings) C++14
0 / 100
27 ms 1184 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;

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

int brute()
{
        ++c;
        set<int> cri;
        for (int i = 0; i < N; ++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)
                        {
                                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 640 KB Output is correct
2 Correct 20 ms 768 KB Output is correct
3 Correct 27 ms 1024 KB Output is correct
4 Incorrect 2 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1184 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 640 KB Output is correct
2 Correct 20 ms 768 KB Output is correct
3 Correct 27 ms 1024 KB Output is correct
4 Incorrect 2 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 20 ms 768 KB Output is correct
3 Correct 27 ms 1024 KB Output is correct
4 Incorrect 2 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 20 ms 768 KB Output is correct
3 Correct 27 ms 1024 KB Output is correct
4 Incorrect 2 ms 640 KB Output isn't correct
5 Halted 0 ms 0 KB -