Submission #618003

# Submission time Handle Problem Language Result Execution time Memory
618003 2022-08-01T19:01:05 Z chirathnirodha Toy Train (IOI17_train) C++17
0 / 100
623 ms 262144 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;
}
bool visited[5000];
bool ok;
void dfs(int x,int ch){
	if(charge[x])ch++;
	if(visited[x] && ch>0){ok=true;return;}
	visited[x]=true;
	for(int i=0;i<ed[x].size();i++){
		int y=ed[x][i];
		dfs(y,ch);
	}
	if(charge[x])ch--;
}

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);
	for(int i=0;i<n;i++){
		memset(visited,false,sizeof(visited));
		ok=false;
		dfs(i,0);
		ans[i]=ok;
	}
	return ans;
	return SUB_1();
}

Compilation message

train.cpp: In function 'void dfs(int, int)':
train.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=0;i<ed[x].size();i++){
      |              ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 129 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 159 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 623 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 140 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -