Submission #134887

# Submission time Handle Problem Language Result Execution time Memory
134887 2019-07-23T11:28:49 Z amiratou Toy Train (IOI17_train) C++14
0 / 100
2000 ms 26092 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> A,R;
int n;
vector<vector<int> > vec;
bool vis[5001][5002];
int dfs(int node,int e,int charge){
	if(R[node])e=n,charge=1;
	//cerr<<node<<" "<<e<<"\n";
	if(!e)return 0;
	//cerr<<vis[node][e]<<"\n";
	if(vis[node][e])
		return 1;
	vis[node][e]=1;
	for(auto child:vec[node]){
		int ans=dfs(child,e-1,charge);
		if(A[node]==ans)return ans;
	}
	return !A[node];
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	//cerr<<"\n----------\n";
	A=a,R=r;
	n=a.size();
	vec.resize(a.size());
	for (int i = 0; i < u.size(); ++i)
		vec[u[i]].push_back(v[i]);
	vector<int> res(n);
	for (int i = 0; i < n; ++i){
		
		memset(vis,0,sizeof vis);
		res[i]=dfs(i,n,0);
		//cerr<<"\n----------\n";
	}
	return res;
}

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:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < u.size(); ++i)
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 26052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 24824 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 Execution timed out 2060 ms 26092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 25592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 25720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 26052 KB Time limit exceeded
2 Halted 0 ms 0 KB -