Submission #823105

# Submission time Handle Problem Language Result Execution time Memory
823105 2023-08-12T08:09:00 Z mindiyak Toy Train (IOI17_train) C++14
0 / 100
4 ms 724 KB
#include "train.h"
#include <queue>
using namespace std;

vector<int> chargers;
vector<int> looped(1e4,0);
vector<int> can_move(1e4,0);
int N;

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	N=a.size();
	if(N==1){
		return {r[0]};
	}
	for(int i=0;i<r.size();i++){if(r[i]==1){chargers.push_back(i);}}

	for (int i = 0; i < u.size(); i++){
		if(u[i] == v[i])looped[i]=1;
		if(u[i]+1 == v[i])can_move[i]=1;
	}
	
	vector<int> ans(N,0);

	ans[N-1] = r[N-1] and looped[N-1];
	for(int i=N-2;i>=0;i--){
		if(r[i] and looped[i]){
			if(a[i])ans[i]=1;
			else{
				if(!can_move[i])ans[i]=1;
			}
		}
		if(ans[i+1] == 1){
			if(a[i] and can_move[i])ans[i]=1;
			else{
				if(can_move[i] and !looped[i])ans[i]=1;
			}
		}
	}

	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:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0;i<r.size();i++){if(r[i]==1){chargers.push_back(i);}}
      |              ~^~~~~~~~~
train.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 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 Incorrect 4 ms 724 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 724 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 4 ms 724 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 2 ms 596 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -