Submission #428657

# Submission time Handle Problem Language Result Execution time Memory
428657 2021-06-15T13:34:20 Z vanic Toy Train (IOI17_train) C++14
11 / 100
475 ms 1860 KB
#include "train.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

const int maxn=5005;

int n, m;
vector < int > ms[maxn];
vector < int > rev[maxn];
int charge[maxn];
int tko[maxn];
bool bio[maxn];
vector < int > sol;
int poc;

int dfs(int x){
	if(bio[x] && x==poc){
		return 1;
	}
	if(bio[x]){
		return 0;
	}
	bio[x]=1;
	for(int i=0; i<(int)ms[x].size(); i++){
		if(dfs(ms[x][i])){
			return 1;
		}
	}
	return 0;
}

void nazad(int x){
	if(sol[x]){
		return;
	}
	sol[x]=1;
	for(int i=0; i<(int)rev[x].size(); i++){
		nazad(rev[x][i]);
	}
}


vector < int > who_wins(vector < int > a, vector < int > r, vector < int > u, vector < int > v) {
	n=a.size();
	m=u.size();
	for(int i=0; i<n; i++){
		tko[i]=a[i];
		charge[i]=r[i];
	}
	for(int i=0; i<m; i++){
		ms[u[i]].push_back(v[i]);
		rev[v[i]].push_back(u[i]);
	}
	sol.resize(n, 0);
	for(int i=0; i<n; i++){
		if(charge[i]){
			poc=i;
			if(dfs(i)){
				nazad(i);
			}
			memset(bio, 0, sizeof(bio));
		}
	}
	return sol;
}
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 1276 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 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 Correct 13 ms 1568 KB Output is correct
2 Correct 38 ms 1708 KB Output is correct
3 Correct 61 ms 1732 KB Output is correct
4 Correct 143 ms 1716 KB Output is correct
5 Correct 30 ms 1688 KB Output is correct
6 Correct 87 ms 1612 KB Output is correct
7 Correct 220 ms 1604 KB Output is correct
8 Correct 9 ms 1612 KB Output is correct
9 Correct 9 ms 1612 KB Output is correct
10 Correct 11 ms 1484 KB Output is correct
11 Correct 9 ms 1560 KB Output is correct
12 Correct 8 ms 1528 KB Output is correct
13 Correct 9 ms 1740 KB Output is correct
14 Correct 9 ms 1740 KB Output is correct
15 Correct 10 ms 1740 KB Output is correct
16 Correct 10 ms 1860 KB Output is correct
17 Correct 10 ms 1740 KB Output is correct
18 Correct 207 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 475 ms 1400 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1612 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 1276 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -