답안 #822891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
822891 2023-08-12T04:58:48 Z mindiyak 장난감 기차 (IOI17_train) C++14
0 / 100
7 ms 996 KB
#include "train.h"
using namespace std;

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int n=a.size();
	vector<vector<int>> paths(n,vector<int> ());

	for (int i = 0; i < u.size(); i++){
		paths[u[i]].push_back(v[i]);
	}
	
	vector<int> ans(n,-1);

	if(r[n-1] == 0)ans[n-1]=0;
	for(int i=n-2;i>=0;i--){
		int win = 1;
		for(int j:paths[i]){
			if(j==i){
				if(r[i] != 1){
					win = (a[i]==1) ? (win|0) : (win&0);
					if(paths.size()==1){
						win = 0;
					}
				}
			}else if(j==i+1){
				win = (a[i]==1) ? (win|ans[i+1]) : (win&ans[i+1]);
				if(paths.size()==1){
					win = 0;
				}
			}
		}
		ans[i] = win;
	}

	return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:8:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 244 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 996 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 896 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 980 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -