답안 #1073296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073296 2024-08-24T11:57:06 Z oscar1f 장난감 기차 (IOI17_train) C++17
11 / 100
10 ms 2224 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;

const int MAX_SOM=5000+5;
int nbSom,nbAre,nbCompo;
vector<int> rep,possed,charg,ordre;
vector<int> adjaTrans[MAX_SOM],adja[MAX_SOM],listeCompo[MAX_SOM];
int compo[MAX_SOM],dv[MAX_SOM],cycle[MAX_SOM];

void DFS(int pos) {
	if (dv[pos]==0) {
		dv[pos]=1;
        for (int i:adja[pos]) {
            DFS(i);
        }
        ordre.push_back(pos);
	}
}

void DFS2(int pos) {
    if (compo[pos]==0) {
        compo[pos]=nbCompo;
        listeCompo[nbCompo].push_back(pos);
        for (int i:adjaTrans[pos]) {
            DFS2(i);
        }
    }
}

void remonte(int pos) {
    if (rep[pos]==0) {
        rep[pos]=1;
        for (int i:adjaTrans[pos]) {
            remonte(i);
        }
    }
}

vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v) {
	nbSom=a.size();
	nbAre=u.size();
	possed=a;
	charg=r;
	rep.resize(nbSom,0);
	for (int i=0;i<nbAre;i++) {
        if (u[i]==v[i]) {
            cycle[u[i]]=1;
        }
		adja[u[i]].push_back(v[i]);
		adjaTrans[v[i]].push_back(u[i]);
	}
	for (int i=0;i<nbSom;i++) {
        DFS(i);
    }
    reverse(ordre.begin(),ordre.end());
    for (int i:ordre) {
        if (compo[i]==0) {
            nbCompo++;
            DFS2(i);
        }
    }
    int presCharg;
    for (int i=1;i<=nbCompo;i++) {
        presCharg=0;
        for (int j:listeCompo[i]) {
            if (charg[j]==1) {
                presCharg=1;
            }
            //cout<<j<<" ";
        }
        //cout<<endl;
        if (presCharg==1 and ((int)listeCompo[i].size()>1 or cycle[listeCompo[i][0]]==1)) {
            remonte(listeCompo[i][0]);
        }
    }
	return rep;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1880 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 604 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2140 KB Output is correct
2 Correct 5 ms 2224 KB Output is correct
3 Correct 5 ms 2140 KB Output is correct
4 Correct 6 ms 1924 KB Output is correct
5 Correct 6 ms 2080 KB Output is correct
6 Correct 7 ms 1880 KB Output is correct
7 Correct 7 ms 1884 KB Output is correct
8 Correct 6 ms 1964 KB Output is correct
9 Correct 5 ms 1832 KB Output is correct
10 Correct 6 ms 1880 KB Output is correct
11 Correct 6 ms 1884 KB Output is correct
12 Correct 10 ms 1784 KB Output is correct
13 Correct 6 ms 2124 KB Output is correct
14 Correct 6 ms 2140 KB Output is correct
15 Correct 6 ms 2020 KB Output is correct
16 Correct 6 ms 1988 KB Output is correct
17 Correct 6 ms 1964 KB Output is correct
18 Correct 4 ms 1788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1884 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1868 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1880 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -