답안 #317384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
317384 2020-10-29T16:35:24 Z mohamedsobhi777 낙하산 고리들 (IOI12_rings) C++14
20 / 100
4000 ms 1348 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;
vector<int> vec;
void dfs(int x, int p)
{
        vis[x] = c;
        int ch = (p != x);
        vec.push_back(x);
        for (auto u : adj[x])
        {
                if (u == p || del == u)
                        continue;
                if (vis[u] == c)
                        bd = 0;
                else
                        dfs(u, x), ++ch;
        }
        if (ch > 2)
                bd = 0;
}
set<int> bigs;

int brute()
{
        set<int> cri;
        for (int i = 0; i < N; ++i)
        {
                ++c;
                del = i;
                for (auto u : adj[i])
                {
                        deg[u]--;
                        deg[i]--;
                }
                bool ok = 1;
                vec.clear();
                for (int j = 0; j < N; ++j)
                {
                        if (vis[j] != c && i != j)
                        {
                                bd = 1;
                                dfs(j, j);
                                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]++;
        if (deg[A] > 3)
                bigs.insert(A);
        if (deg[B] > 3)
                bigs.insert(B);
}

int CountCritical()
{
        if (bigs.size() > 1)
                return 0;
        return brute();
        return N;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 488 ms 864 KB Output is correct
3 Correct 740 ms 1144 KB Output is correct
4 Correct 25 ms 640 KB Output is correct
5 Correct 251 ms 888 KB Output is correct
6 Correct 791 ms 1272 KB Output is correct
7 Correct 256 ms 760 KB Output is correct
8 Correct 387 ms 896 KB Output is correct
9 Correct 753 ms 1016 KB Output is correct
10 Correct 742 ms 1052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1152 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 488 ms 864 KB Output is correct
3 Correct 740 ms 1144 KB Output is correct
4 Correct 25 ms 640 KB Output is correct
5 Correct 251 ms 888 KB Output is correct
6 Correct 791 ms 1272 KB Output is correct
7 Correct 256 ms 760 KB Output is correct
8 Correct 387 ms 896 KB Output is correct
9 Correct 753 ms 1016 KB Output is correct
10 Correct 742 ms 1052 KB Output is correct
11 Execution timed out 4046 ms 1348 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 488 ms 864 KB Output is correct
3 Correct 740 ms 1144 KB Output is correct
4 Correct 25 ms 640 KB Output is correct
5 Correct 251 ms 888 KB Output is correct
6 Correct 791 ms 1272 KB Output is correct
7 Correct 256 ms 760 KB Output is correct
8 Correct 387 ms 896 KB Output is correct
9 Correct 753 ms 1016 KB Output is correct
10 Correct 742 ms 1052 KB Output is correct
11 Execution timed out 4046 ms 1348 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 488 ms 864 KB Output is correct
3 Correct 740 ms 1144 KB Output is correct
4 Correct 25 ms 640 KB Output is correct
5 Correct 251 ms 888 KB Output is correct
6 Correct 791 ms 1272 KB Output is correct
7 Correct 256 ms 760 KB Output is correct
8 Correct 387 ms 896 KB Output is correct
9 Correct 753 ms 1016 KB Output is correct
10 Correct 742 ms 1052 KB Output is correct
11 Runtime error 2 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -