답안 #617978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
617978 2022-08-01T18:34:41 Z chirathnirodha 장난감 기차 (IOI17_train) C++17
0 / 100
2000 ms 99036 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define P push

int n,m;
vector<int> ed[5000];
bool own[5000];
bool charge[5000];
bool self[5000];
vector<int> are,bor;

vector<int> SUB_1() {
	vector<int> ans(n);
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(self[j] && ed[j].size()==1){
				if(charge[j])ans[i]=1;
				else ans[i]=0;
				break;
			}
			if(own[j] && charge[j] && self[j]){ans[i]=1;break;}
			if(!own[j] && !charge[j] && self[j]){ans[i]=0;break;}
		}
	}
	return ans;
}

vector<int> SUB_3(){
	int dp[n][n];memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		for(int j=0;j<ed[i].size();j++){
			dp[i][j]=0;
			if(charge[i] || charge[j])dp[i][j]=1;
		}
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(dp[i][k]==-1 || dp[k][j]==-1 || dp[i][j]==1)continue;
				if(charge[k] || dp[i][k]>0 || dp[k][j]>0)dp[i][j]=1;
				else dp[i][j]=0;
			}
		}
	}
	vector<int> ans(n);
	for(int i=0;i<n;i++){
		if(dp[i][i]==1)ans[i]=1;
		else ans[i]=0;
	}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n=a.size();m=u.size();
	memset(self,false,sizeof(self));
	for(int i=0;i<m;i++){
		ed[u[i]].PB(v[i]);
		if(u[i]==v[i])self[u[i]]=true;
	}
	for(int i=0;i<n;i++){
		own[i]=a[i];
		charge[i]=r[i];
		if(a[i])are.PB(i);
		else bor.PB(i);
	}
	vector<int> ans(n);
	if(bor.size()==0)return SUB_3();
	else return SUB_1();

	return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> SUB_3()':
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 j=0;j<ed[i].size();j++){
      |               ~^~~~~~~~~~~~~
train.cpp:55:1: warning: no return statement in function returning non-void [-Wreturn-type]
   55 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 852 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 3 ms 852 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 4 ms 804 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 3 ms 852 KB Output is correct
8 Execution timed out 2075 ms 98636 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 420 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2069 ms 99036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1108 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1324 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 852 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 3 ms 852 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 4 ms 804 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 3 ms 852 KB Output is correct
8 Execution timed out 2075 ms 98636 KB Time limit exceeded
9 Halted 0 ms 0 KB -