답안 #134873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134873 2019-07-23T11:07:39 Z amiratou 장난감 기차 (IOI17_train) C++14
0 / 100
1450 ms 1424 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> A,R;
int n;
vector<vector<int> > vec;
int vis[5001];
int dfs(int node,int e,int charge){
	if(R[node])e=n,charge=1;
	//cerr<<node<<" "<<e<<"\n";
	if(!e)return 0;
	if(vis[node]!=-1){
		if(charge)return 1;
		else return 0;
	}
	vis[node]=e;
	for(auto child:vec[node]){
		int ans=dfs(child,e-1,charge);
		if(A[node]&&ans==1)return 1;
		if(!A[node]&&ans==0)return 0;
	}
	return !A[node];
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	//cerr<<"\n----------\n";
	A=a,R=r;
	n=a.size();
	vec.resize(a.size());
	for (int i = 0; i < u.size(); ++i)
		vec[u[i]].push_back(v[i]);
	vector<int> res(n);
	for (int i = 0; i < n; ++i){
		
		memset(vis,-1,sizeof vis);
		res[i]=dfs(i,n,0);
		//cerr<<"\n----------\n";
	}
	return res;
}

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:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < u.size(); ++i)
                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 888 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 230 ms 1424 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1258 ms 1144 KB 3rd lines differ - on the 75th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1450 ms 1228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 888 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -