Submission #409798

# Submission time Handle Problem Language Result Execution time Memory
409798 2021-05-21T14:57:04 Z dreezy Toy Train (IOI17_train) C++17
5 / 100
8 ms 608 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+0; i<= min(curstation, n-1); i++){
			//cout << i<<", "<<curstation<<endl;
			w[i] = winner;
		}		
		--i;
	}
	
	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,v);
	for(int i=0; i< n ;i++)
		cout << w[i]<<endl;
}*/
# Verdict Execution time Memory Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 4 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 4 ms 380 KB Output is correct
9 Correct 6 ms 460 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
# 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 7 ms 608 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 7 ms 588 KB Output is correct
4 Incorrect 8 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 Correct 4 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 4 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 4 ms 380 KB Output is correct
9 Correct 6 ms 460 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Incorrect 1 ms 204 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -