Submission #426944

# Submission time Handle Problem Language Result Execution time Memory
426944 2021-06-14T11:04:58 Z oscar1f Toy Train (IOI17_train) C++17
0 / 100
2000 ms 1448 KB
#include<bits/stdc++.h>
/*#include <cstdio>
#include <vector>
#include <cassert>*/
#include "train.h"
using namespace std;

const int MAX_GARE=5000;
int nbGare,nbChemin,deb;
vector<int> adja[MAX_GARE];
deque<int> aTraiter;
int dv[MAX_GARE];
int charge[MAX_GARE],bon[MAX_GARE];
vector<int> rep;

void DFS_2(int pos) {
	if (charge[pos]==0) {
		if (dv[pos]!=deb+1) {
			dv[pos]=deb+1;
			for (int ivois=0;ivois<adja[pos].size();ivois++) {
				DFS_2(adja[pos][ivois]);
			}
		}
		else if (pos==deb) {
			bon[deb]=1;
		}
	}
}

void DFS(int pos) {
	if (charge[pos]==0) {
		if (dv[pos]!=deb+1) {
			if (bon[pos]==1) {
				rep[deb]=0;
			}
			dv[pos]=deb+1;
			for (int ivois=0;ivois<adja[pos].size();ivois++) {
				DFS(adja[pos][ivois]);
			}
		}
	}
}

vector<int> who_wins(vector<int> posses, vector<int> recharge, vector<int> dep, vector<int> arriv) {
	nbGare=posses.size();
	for (int i=0;i<nbGare;i++) {
		rep.push_back(1);
		charge[i]=recharge[i];
	}
	nbChemin=dep.size();
	for (int i=0;i<nbChemin;i++) {
		adja[dep[i]].push_back(arriv[i]);
	}
	for (int i=0;i<nbGare;i++) {
		deb=i;
		DFS_2(deb);
	}
	for (int i=0;i<MAX_GARE;i++) {
		dv[i]=0;
	}
	for (int i=0;i<nbGare;i++) {
		deb=i;
		DFS(deb);
	}
	return rep;
}

/*int main() {
	int n, m;
	assert(2 == scanf("%d %d", &n, &m));

	vector<int> a(n), r(n), u(m), v(m);

	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &a[i]));

	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &r[i]));

	for(int i = 0; i < m; i++)
		assert(2 == scanf("%d %d", &u[i], &v[i]));

	vector<int> res = who_wins(a, r, u, v);

	for(int i = 0; i < (int)res.size(); i++)
		printf(i ? " %d" : "%d", res[i]);
	printf("\n");

	return 0;
}*/

Compilation message

train.cpp: In function 'void DFS_2(int)':
train.cpp:20:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |    for (int ivois=0;ivois<adja[pos].size();ivois++) {
      |                     ~~~~~^~~~~~~~~~~~~~~~~
train.cpp: In function 'void DFS(int)':
train.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for (int ivois=0;ivois<adja[pos].size();ivois++) {
      |                     ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 936 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 1448 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1072 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 Execution timed out 2041 ms 1360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 936 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -