답안 #823088

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

vector<vector<int>> paths(1e4,vector<int> ());
vector<int> chargers;
vector<int> looped(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;
		else paths[u[i]].push_back(v[i]);
	}
	
	vector<int> ans(N,0);

	for(int i=0;i<N;i++){
		if(r[i]=1){
			if(a[i]==1 and looped[i])ans[i]=1;
			if(a[i]==0 and looped[i] and paths[i].size() == 0)ans[i]=1;
		}
		if(i!=N-1 and r[i+1]==1 and paths[i].size()>0){
			if(a[i+1]==1 and looped[i+1])ans[i]=1;
			if(a[i+1]==0 and looped[i+1] and paths[i+1].size() == 0)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++){
      |                  ~~^~~~~~~~~~
train.cpp:25:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   25 |   if(r[i]=1){
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 980 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1364 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1356 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 980 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -