Submission #409797

# Submission time Handle Problem Language Result Execution time Memory
409797 2021-05-21T14:51:09 Z dreezy Toy Train (IOI17_train) C++17
0 / 100
6 ms 616 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u , vector<int> v){
	int n = a.size();
	int m = u.size();
	
	vector<int > w(n);
	vector<bool> iscycle(n, 0);
	vector<bool> hasout(n, 0);
	
	for(int i =0; i< m; i++){
		if(u[i] == v[i]){
			iscycle[u[i]] = true;
		}
		else
			hasout[u[i]] = true;
		
	}
	for(int i =0; i< n; i++){
		int winner = 0;
		int energy = n;
		
		int curstation = i;
		while(curstation < n){
			
			if(iscycle[curstation]){
				if(a[curstation] && r[curstation]){
					winner = 1;
					break;
				}
				else if(!a[curstation] && !r[curstation]){
					winner = 0;
					break;
				}
				else if(a[curstation] && !r[curstation] && !hasout[curstation]){
					winner = 0;
					break;
				}
				else if(!a[curstation] && r[curstation] && !hasout[curstation]){
					winner = 1;
					break;
				}
			}
			if(energy == 0){
				winner = 0;
				break;
			}
			energy--;
			curstation++;
		}
		
		for(i = i; i<= min(curstation, n-1); i++){
			w[i] = winner;
		}		
	}
	
	return w;
}

/*
int main(){
	int n, m; cin >> n >>m;
	vector<int> a(n), r(n), u(m) ,v(m);
	for(int i  = 0; i<n; i++){
		cin >> a[i];
	}
	for(int i =0; i< n; i++)
		cin >> r[i];
	for(int i =0; i<m; i++)
	cin >> u[i];
	for(int i =0; i<m;i++)
	cin >> v[i];
	
	vector<int> w = who_wins(a,r,u,m);
	for(int i=0; i< n ;i++)
		cout << w[i]<<endl;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 460 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 588 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 6 ms 616 KB Output is correct
4 Incorrect 6 ms 588 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 588 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 588 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 460 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -