답안 #426808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426808 2021-06-14T10:01:39 Z oscar1f 장난감 기차 (IOI17_train) C++17
0 / 100
9 ms 1484 KB
#include<bits/stdc++.h>
/*#include <cstdio>
#include <vector>
#include <cassert>*/
#include "train.h"
using namespace std;

const int MAX_GARE=5000;
int nbGare,nbChemin,longueur,pos;
vector<int> adja[MAX_GARE],adjaTrans[MAX_GARE];
deque<int> aTraiter;
int nbBon[MAX_GARE];
int dv[MAX_GARE];

vector<int> who_wins(vector<int> posses, vector<int> recharge, vector<int> dep, vector<int> arriv) {
	vector<int> rep;
	rep.clear();
	nbGare=posses.size();
	for (int i=0;i<nbGare;i++) {
		rep.push_back(i);
	}
	nbChemin=dep.size();
	for (int i=0;i<nbChemin;i++) {
		adja[dep[i]].push_back(arriv[i]);
		adjaTrans[arriv[i]].push_back(dep[i]);
	}
	for (int i=0;i<nbGare;i++) {
		if (recharge[i]==1) {
			aTraiter.push_back(i);
		}
	}
	while (aTraiter.size()>0) {
		longueur=aTraiter.size();
		for (int i=0;i<longueur;i++) {
			pos=aTraiter.front();
			aTraiter.pop_front();
			nbBon[pos]++;
			if (dv[pos]==0 and (recharge[pos]==1 or posses[pos]==1 or nbBon[pos]==adja[pos].size())) {
				dv[pos]=1;
				rep[pos]=1;
				for (int ivois=0;ivois<adjaTrans[pos].size();ivois++) {
					aTraiter.push_back(adjaTrans[pos][ivois]);
				}
			}
		}
	}
	return rep;
}
/*
int main() {
	int n, m;
	assert(2 == scanf("%d %d", &n, &m));

	vector<int> a(n), r(n), u(m), v(m);

	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &a[i]));

	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &r[i]));

	for(int i = 0; i < m; i++)
		assert(2 == scanf("%d %d", &u[i], &v[i]));

	vector<int> res = who_wins(a, r, u, v);

	for(int i = 0; i < (int)res.size(); i++)
		printf(i ? " %d" : "%d", res[i]);
	printf("\n");

	return 0;
}
*/

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:38:72: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    if (dv[pos]==0 and (recharge[pos]==1 or posses[pos]==1 or nbBon[pos]==adja[pos].size())) {
      |                                                              ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
train.cpp:41:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int ivois=0;ivois<adjaTrans[pos].size();ivois++) {
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1104 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1484 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1204 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1356 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1104 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -