답안 #428587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428587 2021-06-15T13:02:37 Z vanic 장난감 기차 (IOI17_train) C++14
0 / 100
2000 ms 1568 KB
#include "train.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const int maxn=5005;

int n, m;
vector < int > ms[maxn];
int charge[maxn];
bool tko[maxn];
bool bio[maxn];
vector < int > sol;
vector < int > put;

int dfs(int x){
	if(bio[x]){
		bool p=0;
		for(int i=0; i<n; i++){
			if(put[i]==x){
				p=1;
			}
			if(p){
				if(charge[put[i]]){
					return 1;
				}
			}
		}
		return 0;
	}
	put.push_back(x);
	bio[x]=1;
	for(int i=0; i<ms[x].size(); i++){
		if(dfs(ms[x][i])==tko[x]){
			bio[x]=0;
			put.pop_back();
			return tko[x];
		}
	}
	bio[x]=0;
	put.pop_back();
	return !tko[x];
}

vector < int > who_wins(vector < int > a, vector < int > r, vector < int > u, vector < int > v) {
	n=a.size();
	m=u.size();
	for(int i=0; i<n; i++){
		tko[i]=a[i];
		charge[i]=r[i];
	}
	for(int i=0; i<m; i++){
		ms[u[i]].push_back(v[i]);
	}
	sol.resize(n, 0);
	for(int i=0; i<n; i++){
		sol[i]=dfs(i);
	}
	
	return sol;
}

Compilation message

train.cpp: In function 'int dfs(int)':
train.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i=0; i<ms[x].size(); i++){
      |               ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1436 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 208 ms 1568 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 1228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 1308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1436 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -