Cod sursa(job #2509503)

Utilizator Vaida_Radu_AndreiVaida Radu Andrei Vaida_Radu_Andrei Data 14 decembrie 2019 11:57:31
Problema Componente tare conexe Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.44 kb
#include <cstdio>
#include <vector>
#define VerticesMax 101024

using namespace std;

int VerticesLength,Ctc[VerticesMax],CtcCodesLength=1;
vector <int> Graph[2][VerticesMax]; ///points from index to the next vertice

void read() {
    int I,EdgesLength,From,To;
    scanf("%d%d",&VerticesLength,&EdgesLength);
    for(I=0;I<EdgesLength;++I) {
        scanf("%d%d",&From,&To);
        --From;
        --To;
        Graph[0][From].push(To);
        Graph[1][To].push(From);
    }
}

void goThrough(vector <int> Graphy[],int Reached[]) {
}

void fillCtc(int Start) {
    int K;
    int Reached[2][VerticesLength];
    for(K=0;K<2;++K) {
        goThrough(Graph[K],Reached[K]);
    }
    for(K=0;K<VerticesLength;++K) {
        if(Reached[0][K]&&Reached[1][K]) {
            Ctc[K]=CtcCodesLength;
        }
    }
    ++CtcCodesLength;
}

void solve() {
    int I;
    for(I=0;I<VerticesLength;++I) {
        if(!Ctc[I]) {
            fillCtc(I);
        }
    }
}

void display() {
    ///divide
    int I;
    vector <int> Ctcs[CtcCodesLength];
    for(I=0;I<VerticesLength;++I) {
        Ctcs[Ctc[I]].push(I);
    }
    ///show
    printf("%d\n",CtcCodesLength);
    for(I=0;I<CtcCodesLength;++I) {
        for(auto V:Ctcs[I]) {
            printf("%d ",V);
        }
        printf("\n");
    }
}

int main()
{
    freopen("ctc.in","r",stdin);
    freopen("ctc.out","w",stdout);
    read();
    return 0;
}