답안 #822872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
822872 2023-08-12T04:55:33 Z mindiyak 장난감 기차 (IOI17_train) C++14
0 / 100
5 ms 1236 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);
				}
			}else if(j==i+1){
				win = (a[i]==1) ? (win|ans[i+1]) : (win&ans[i+1]);
			}
		}
		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 3 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1236 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1060 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1236 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -