답안 #424952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
424952 2021-06-12T11:57:41 Z MeGustaElArroz23 장난감 기차 (IOI17_train) C++14
0 / 100
2000 ms 1616 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;

void debug(vi v){
	for (int x:v) cerr << x << ' ';
	cerr<<'\n';
}

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;
	vector<int> chargin;
	for (int i=0;i<n;i++){
		if (charge[i]) chargin.push_back(i);
	}
	//cerr<<0;
	for (int x:chargin){
		vector<bool> porvisitar(n,true);
		queue<int> cola;
		cola.push(x);
		bool T=true;
		while (cola.size()){
			//cerr<<1;
			int ac=cola.front();
			//cerr<< ' ' << ac << ' ' <<cola.size()<<'\n';
			//cerr<<2;
			cola.pop();
			//cerr<<3;
			if (porvisitar[ac]){
				//cerr<<4;
				porvisitar[ac]=false;
				//cerr<<5;
				for (int y:conexiones[ac]) cola.push(y);
				//cerr<<6;
			}
			else if (ac==x) T=false;
		}
		//cerr<<7;
		if (not T) charging.insert(x);
	}
	//cerr<<1;
	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);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 460 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 182 ms 1524 KB Output is correct
2 Correct 188 ms 1500 KB Output is correct
3 Correct 242 ms 1572 KB Output is correct
4 Execution timed out 2073 ms 1616 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 716 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 844 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 460 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -