Submission #822872

# Submission time Handle Problem Language Result Execution time Memory
822872 2023-08-12T04:55:33 Z mindiyak Toy Train (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++){
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -