Submission #617983

# Submission time Handle Problem Language Result Execution time Memory
617983 2022-08-01T18:37:54 Z chirathnirodha Toy Train (IOI17_train) C++17
5 / 100
10 ms 1408 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;
	}
  	return ans;
}
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);
	}
  	return SUB_1();
	if(bor.size()==0)return SUB_3();
}

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++){
      |               ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 4 ms 724 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 3 ms 724 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 4 ms 724 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 4 ms 852 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1108 KB Output is correct
2 Correct 8 ms 1236 KB Output is correct
3 Correct 9 ms 1408 KB Output is correct
4 Incorrect 10 ms 1236 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 980 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1092 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 4 ms 724 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 3 ms 724 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 4 ms 724 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 4 ms 852 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Incorrect 0 ms 340 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -