답안 #409796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409796 2021-05-21T14:49:49 Z dreezy 장난감 기차 (IOI17_train) C++17
0 / 100
9 ms 612 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[i]){
				if(a[i] && r[i]){
					winner = 1;
					break;
				}
				else if(!a[i] && !r[i]){
					winner = 0;
					break;
				}
				else if(a[i] && !r[i] && !hasout[i]){
					winner = 0;
					break;
				}
				else if(!a[i] && r[i] && !hasout[i]){
					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;
}*/
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 612 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 7 ms 588 KB Output is correct
4 Incorrect 9 ms 588 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 588 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -