Submission #33539

# Submission time Handle Problem Language Result Execution time Memory
33539 2017-10-29T16:44:02 Z mohammad_kilani Toy Train (IOI17_train) C++14
5 / 100
2000 ms 210964 KB
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
const int N = 5010;
int n ;
bitset< N > dp[N] , vis[N];
vector<int> a, r;
vector<int> g[N];
bool solve(int i,int j){
	if(r[i]) j = n;
	if(j == 0) return 0;
	if(vis[i][j]) return dp[i][j];
	vis[i][j] = 1;
	dp[i][j] = 1;
	if(!a[i]){
		for(int k=0;k<g[i].size();k++){
			int node = g[i][k];
			if(solve(node,j-1) == 0) dp[i][j] = 0;
		}
	}
	else{
		bool can = false;
		for(int k=0;k<g[i].size();k++){
			int node = g[i][k];
			if(solve(node,j-1) == 1) can = true;
		}
		dp[i][j] = can;
	}
	return dp[i][j];
}


std::vector<int> who_wins(std::vector<int> A, std::vector<int> R, std::vector<int> u, std::vector<int> v) {
	vector<int> ans;
	a = A;
	r = R;;
	n = a.size();
	for(int i=0;i<u.size();i++) g[u[i]].push_back(v[i]);
	for(int i=0;i<n;i++) ans.push_back(solve(i,n));
	return ans;
}

Compilation message

train.cpp: In function 'bool solve(int, int)':
train.cpp:16:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=0;k<g[i].size();k++){
                ^
train.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=0;k<g[i].size();k++){
                ^
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:38:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<u.size();i++) g[u[i]].push_back(v[i]);
               ^
# Verdict Execution time Memory Grader output
1 Correct 136 ms 153424 KB Output is correct
2 Correct 173 ms 80632 KB Output is correct
3 Correct 136 ms 48132 KB Output is correct
4 Correct 143 ms 25832 KB Output is correct
5 Correct 139 ms 17608 KB Output is correct
6 Correct 136 ms 12120 KB Output is correct
7 Correct 143 ms 12908 KB Output is correct
8 Correct 139 ms 13292 KB Output is correct
9 Correct 143 ms 10952 KB Output is correct
10 Correct 159 ms 9792 KB Output is correct
11 Correct 226 ms 8992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8320 KB Output is correct
2 Correct 0 ms 8320 KB Output is correct
3 Correct 0 ms 8320 KB Output is correct
4 Incorrect 0 ms 8320 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 506 ms 9552 KB Output is correct
2 Correct 349 ms 9520 KB Output is correct
3 Correct 366 ms 9516 KB Output is correct
4 Correct 1956 ms 210964 KB Output is correct
5 Execution timed out 2000 ms 47288 KB Execution timed out
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 9200 KB Output is correct
2 Correct 79 ms 9184 KB Output is correct
3 Incorrect 89 ms 9360 KB 3rd lines differ - on the 282nd token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2000 ms 9208 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 136 ms 153424 KB Output is correct
2 Correct 173 ms 80632 KB Output is correct
3 Correct 136 ms 48132 KB Output is correct
4 Correct 143 ms 25832 KB Output is correct
5 Correct 139 ms 17608 KB Output is correct
6 Correct 136 ms 12120 KB Output is correct
7 Correct 143 ms 12908 KB Output is correct
8 Correct 139 ms 13292 KB Output is correct
9 Correct 143 ms 10952 KB Output is correct
10 Correct 159 ms 9792 KB Output is correct
11 Correct 226 ms 8992 KB Output is correct
12 Correct 0 ms 8320 KB Output is correct
13 Correct 0 ms 8320 KB Output is correct
14 Correct 0 ms 8320 KB Output is correct
15 Incorrect 0 ms 8320 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
16 Halted 0 ms 0 KB -