Submission #822928

# Submission time Handle Problem Language Result Execution time Memory
822928 2023-08-12T05:14:40 Z mindiyak Toy Train (IOI17_train) C++14
0 / 100
2000 ms 262144 KB
#include "train.h"
using namespace std;

vector<vector<int>> paths(1e4,vector<int> ());
vector<int> chargers;
// vector<int> cost(1e4,-1);

int loop = 0;
int n;

void dfs(int pos,int start,int coins,int charging){
	if(loop==1)return;
	if(chargers[pos] == 1){
		charging = 1;
		coins = n;
	}
	if(pos==start and charging==1){loop = 1;}
	coins--;
	if(coins <= 0)return;
	for(int a:paths[pos]){
		dfs(a,start,coins,charging);
	}
}

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	n=a.size();
	chargers = a;
	for (int i = 0; i < u.size(); i++){
		paths[u[i]].push_back(v[i]);
	}
	
	vector<int> ans(n,-1);

	
	for (int i = 0; i < u.size(); i++){
		loop = 0;
		dfs(i,i,n,chargers[i]);
		ans[i] = loop;
	}

	return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
train.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 120 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 108 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 2132 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2065 ms 1268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 117 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 120 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -