답안 #1104699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104699 2024-10-24T09:02:12 Z alexander707070 장난감 기차 (IOI17_train) C++14
0 / 100
20 ms 27728 KB
#include<bits/stdc++.h>
#define MAXN 1000007
using namespace std;

int n;
bool is[MAXN],sp[MAXN];
vector<int> v[MAXN],ans;
int tim[MAXN];

bool brute(int x,int last,int t){
	tim[x]=t;
	if(sp[x])last=t;

	for(int i=0;i<v[x].size();i++){
		if(is[x]){
			if(tim[v[x][i]]!=0 and tim[v[x][i]]<=t)return true;
		}else{
			if(tim[v[x][i]]!=0 and tim[v[x][i]]>t)return false;
		}
	}

	for(int i=0;i<v[x].size();i++){
		if(tim[v[x][i]]!=0)continue;

		if(is[x]){
			if(brute(v[x][i],last,t+1))return true;
		}else{
			if(!brute(v[x][i],last,t+1))return false;
		}
	}

	tim[x]=0;
	return !is[x];
}

vector<int> who_wins(vector<int> A,vector<int> R, vector<int> from,vector<int> to){
	n=int(A.size());

	for(int i=1;i<=n;i++){
		is[i]=A[i-1];
		sp[i]=R[i-1];
	}

	for(int i=1;i<=from.size();i++){
		v[from[i-1]+1].push_back(to[i-1]+1);
	}

	if(n<=15){
		for(int i=1;i<=n;i++){
			for(int f=1;f<=n;f++)tim[f]=0;

			if(brute(i,0,1))ans.push_back(1);
			else ans.push_back(0);
		}
	}

	return ans;
}

/*int main(){

	ans=who_wins({0, 1}, {1, 0}, {0, 0, 1, 1}, {0, 1, 0, 1});

	for(int i:ans)cout<<i<<" ";

	return 0;
}*/

Compilation message

train.cpp: In function 'bool brute(int, int, int)':
train.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<v[x].size();i++){
      |              ~^~~~~~~~~~~~
train.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=0;i<v[x].size();i++){
      |              ~^~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(int i=1;i<=from.size();i++){
      |              ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 27472 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 26960 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 27728 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 26112 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 26624 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 27472 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -