Submission #424912

# Submission time Handle Problem Language Result Execution time Memory
424912 2021-06-12T11:29:54 Z MeGustaElArroz23 Toy Train (IOI17_train) C++14
0 / 100
8 ms 2508 KB

#include <cstdio>
#include <vector>
#include <cassert>

#include "train.h"
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

bool escaso1(vector<int> who){
	for (int x:who){
		if (x==0) return 0;
	}
	return 1;
}

vi caso_todos1(vector<int> who, vector<int> charge, vector<int> u, vector<int> v){
	int n=who.size();
	int m=u.size();
	vi sol(n);
	vvi conexiones(n);
	for (int i=0;i<m;i++){
		conexiones[u[i]].push_back(v[i]);
	}
	set<int> charging;
	for (int i=0;i<n;i++){
		if (charge[i]) charging.insert(i);
	}
	for (int x:charging){
		vector<bool> porvisitar(n,true);
		queue<int> cola;
		cola.push(x);
		bool T=true;
		while (cola.size()){
			int ac=cola.front();
			cola.pop();
			if (porvisitar[ac]){
				porvisitar[ac]=false;
				for (int y:conexiones[ac]) cola.push(y);
			}
			else if (ac==x) T=false;
		}
		if (T) charging.erase(x);
	}
	for (int x=0;x<n;x++){
		vector<bool> porvisitar(n,true);
		queue<int> cola;
		cola.push(x);
		bool T=true;
		while (cola.size()){
			int ac=cola.front();
			cola.pop();
			if (porvisitar[ac]){
				if (charging.count(ac)) T=false;
				porvisitar[ac]=false;
				for (int y:conexiones[ac]) cola.push(y);
			}
		}
		if (T){
			sol[x]=0;
		}
		else sol[x]=1;
	}
	return sol;
}

vector<int> who_wins(vector<int> who, vector<int> charge, vector<int> u, vector<int> v) {
	if (escaso1(who)) return caso_todos1(who,charge,u,v);
	return vi(0);
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 2508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 716 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 844 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -