답안 #822938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
822938 2023-08-12T05:27:43 Z mindiyak 장난감 기차 (IOI17_train) C++14
0 / 100
2000 ms 73388 KB
#include "train.h"
using namespace std;

vector<vector<int>> paths(1e4,vector<int> ());
vector<int> chargers(1e4);
vector<int> cost(1e4,1e9);

int loop = 0;
int n;

void dfs(int pos,int start,int coins,int charging,vector<int> visited,int time){
	if(cost[pos] <= coins){
		cost[pos] = min(cost[pos],time);
		loop = 1;
	}
	if(visited[pos]){
		if(chargers[pos] == 1){
			cost[pos] = min(cost[pos],time);
			loop = 1;
		}
		return;
	}
	if(loop==1)return;
	if(chargers[pos] == 1){
		if(time == -1){
			time = n-coins;
		}
		charging = 1;
		coins = n;
	}
	if(pos==start and charging==1){cost[pos] = min(cost[pos],time);loop = 1;}
	coins--;
	visited[pos]=1;
	if(coins <= 0)return;
	for(int a:paths[pos]){
		dfs(a,start,coins,charging,visited,time);
	}
}

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

	
	for (int i = 0; i < n; i++){
		loop = 0;
		dfs(i,i,n,chargers[i],vector<int>(n,0),-1);
		ans[i] = loop;
	}

	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:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 2376 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 596 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 73388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 2236 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 472 ms 2020 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 2376 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -