Submission #72867

# Submission time Handle Problem Language Result Execution time Memory
72867 2018-08-27T06:28:00 Z Sa1378 Toy Train (IOI17_train) C++17
0 / 100
15 ms 1452 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define N ((int)100)

int n,m,arr[N];
bool e[N][N],mark[N];
vector <int> now;

bool solve(vector <int> &a,vector <int> &r)
{
	int x=now.back();
	bool flg=0;
	for(int i=(int)now.size()-1;i>=0;i--)
	{
		flg|=r[now[i]];
	//	cout<<flg<<" "<<now[i]<<" "<<e[x][now[i]]<<"\n";
		if(e[x][now[i]] && flg==a[x])return a[x];
	}
	srand(time(NULL));
	random_shuffle(arr,arr+n);
	for(int j=0;j<n;j++)
	{
		int i=arr[j];
		if(mark[i] || !e[x][i])continue;
		now.push_back(i);mark[i]=1;
		if(solve(a,r)==a[x])
		{
			now.pop_back();mark[i]=0;
			return a[x];
		}
		now.pop_back();mark[i]=0;
	}
	return 1-a[x];
}


vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v)
{
	n=a.size();m=u.size();
	for(int i=0;i<n;i++)arr[i]=i;
	for(int i=0;i<m;i++)e[u[i]][v[i]]=1;
	vector <int> res;
	for(int i=0;i<n;i++)
	{
		now.push_back(i);mark[i]=1;
		res.push_back(solve(a,r));
		now.pop_back();mark[i]=0;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 788 KB 3rd lines differ - on the 5th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 1320 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 1332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1452 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -