Submission #607539

# Submission time Handle Problem Language Result Execution time Memory
607539 2022-07-26T19:47:29 Z Arturgo Toy Train (IOI17_train) C++14
23 / 100
1341 ms 1364 KB
#include "train.h"
#include <deque>
#include <vector>
using namespace std;

int nbSommets;
vector<int> nouvDegs;
vector<bool> nouvGagnants;
vector<int> estMax;

vector<int> parents[6000];

void explore(int sommet) {
	for(int parent : parents[sommet]) {
		if(nouvGagnants[parent]) continue;
		
		if(estMax[parent]) {
			nouvGagnants[parent] = true;
			explore(parent);
		}
		else {
			nouvDegs[parent]--;
			if(nouvDegs[parent] == 0) {
				nouvGagnants[parent] = true;
				explore(parent);
			}
		}
	}	
}

vector<int> who_wins(vector<int> _estMax, vector<int> estRecharge,
 vector<int> debs, vector<int> fins) {
 	estMax = _estMax;
	nbSommets = estMax.size();
	
	vector<int> degs(nbSommets, 0);
	
	for(int iArc = 0;iArc < (int)debs.size();iArc++) {
		parents[fins[iArc]].push_back(debs[iArc]);
		degs[debs[iArc]]++;
	}
	
	int nbRecharges = 0;
	for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
		if(estRecharge[iSommet])
			nbRecharges += 1;
	}
	
	vector<bool> gagnants(nbSommets, true);
	
	for(int iFois = 0;iFois <= nbRecharges + 3;iFois++) {
		nouvDegs = degs;
		nouvGagnants = vector<bool>(nbSommets, false);
		
		for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
			if(gagnants[iSommet] && estRecharge[iSommet]) {
				explore(iSommet);
			}
		}
		
		gagnants = nouvGagnants;
	}
	
	vector<int> estGagnant;
	for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
		estGagnant.push_back(gagnants[iSommet]);
	}
	
	return estGagnant;
}
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 844 KB 3rd lines differ - on the 22nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1312 KB Output is correct
2 Correct 77 ms 1364 KB Output is correct
3 Correct 114 ms 1316 KB Output is correct
4 Correct 264 ms 1196 KB Output is correct
5 Correct 52 ms 1108 KB Output is correct
6 Correct 11 ms 1104 KB Output is correct
7 Correct 608 ms 1076 KB Output is correct
8 Correct 8 ms 1108 KB Output is correct
9 Correct 6 ms 992 KB Output is correct
10 Correct 9 ms 1108 KB Output is correct
11 Correct 7 ms 1108 KB Output is correct
12 Correct 6 ms 980 KB Output is correct
13 Correct 7 ms 1304 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 8 ms 1236 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 7 ms 1236 KB Output is correct
18 Correct 199 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1341 ms 968 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1132 KB Output is correct
2 Correct 9 ms 1260 KB Output is correct
3 Correct 7 ms 1136 KB Output is correct
4 Correct 9 ms 1108 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 5 ms 852 KB Output is correct
8 Correct 5 ms 852 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 844 KB 3rd lines differ - on the 22nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -