답안 #64461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64461 2018-08-04T14:22:12 Z zubec 낙하산 고리들 (IOI12_rings) C++14
0 / 100
4000 ms 44772 KB
#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;

const int N = 1000100;

vector<int> g[N];

int tin[N], fup[N], tim, ans, n;

bool used[N];

void dfs(int v, int p){
    tin[v] = fup[v] = ++tim;
    int children = 0;
    bool isCutpoint = 0;
    for (int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if (to == p)
            continue;
        if (used[to]){
            fup[v] = min(fup[v], tin[to]);
        } else {
            dfs(to, v);
            ++children;
            fup[v] = min(fup[v], fup[to]);
            if (tin[v] <= fup[to] && p != -1 && !isCutpoint){
                ++ans;
                isCutpoint = 0;
            }
        }
    }
    if (p == -1 && children > 1){
        ++ans;
    }
}

void Init(int n){
    ::n = n;
    for (int i = 1; i <= n; i++)
        g[i].clear();
}



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


int CountCritical(){
    for (int i = 1; i <= n; i++){
        used[i] = tin[i] = fup[i] = 0;
    }
    tim = 0;
    ans = 0;
    for (int i = 1; i <= n; i++){
        if (!used[i])
            dfs(i, 0);
    }
    return ans;
}

Compilation message

rings.cpp: In function 'void dfs(int, int)':
rings.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < g[v].size(); i++){
                     ~~^~~~~~~~~~~~~
rings.cpp: In function 'int CountCritical()':
rings.cpp:56:26: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
         used[i] = tin[i] = fup[i] = 0;
                   ~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4029 ms 44772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -