Submission #402835

# Submission time Handle Problem Language Result Execution time Memory
402835 2021-05-12T12:14:55 Z kshitij_sodani Toy Train (IOI17_train) C++14
11 / 100
2000 ms 1892 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'

#include "train.h"
vector<int> adj[5001];
vector<int> adj2[5001];
vector<int> adj3[5001];
int cyc[5001];
int vis[5001];
int ok=0;
int cur=-1;
void dfs(int no){
	vis[no]=1;
	for(auto j:adj2[no]){
		if(vis[j]==0){
			dfs(j);
		}
		else if(vis[j]==1){
			if(j==cur){
				ok=1;
			}
		}
	}
}
void dfs2(int no){
	vis[no]=1;
	for(auto j:adj[no]){
		if(vis[j]==0){
			dfs2(j);
		}

	}
}
vector<int> who_wins(vector<int> aa, vector<int> bb,vector<int> uu,vector<int> vv) {
	int n=aa.size();
	int m=uu.size();
	for(int i=0;i<m;i++){
		adj[uu[i]].pb(vv[i]);
		if(bb[uu[i]]==0 and bb[vv[i]]==0){
			adj2[uu[i]].pb(vv[i]);
		}
	}
	for(int i=0;i<n;i++){
		if(bb[i]==0){
			cur=i;
			for(int j=0;j<n;j++){
				vis[j]=0;
			}
			ok=0;
			dfs(i);
			cyc[i]=ok;
		}
		else{
			cyc[i]=0;
		}
	}
	vector<int> ans;
	for(int i=0;i<n;i++){
		ans.pb(1);
		for(int j=0;j<n;j++){
			vis[j]=0;
		}
		dfs2(i);
		for(int j=0;j<n;j++){
			if(vis[j]==1 and cyc[j]==1){
				ans[i]=0;
			}
		}

		/*for(int j=i;j<n;j++){
			int st=0;
			int st2=0;
			for(auto ii:adj[j]){
				if(ii==j){
					st=1;
				}
				if(ii==j+1){
					st2=1;
				}
			}
			if(st==1){
				if(st2==0){
					if(bb[j]==1){
						ans[i]=1;
					}
					else{

					}
					break;
				}
				if(aa[j]==0){
					if(bb[j]==0){
						break;
					}
				}
				if(aa[j]==1 and bb[j]==1){

					ans[i]=1;
					break;
				}
			}
		}*/
	}



	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 246 ms 1100 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 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 346 ms 1744 KB Output is correct
2 Correct 309 ms 1688 KB Output is correct
3 Correct 283 ms 1580 KB Output is correct
4 Incorrect 1571 ms 1492 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 Correct 828 ms 1312 KB Output is correct
2 Correct 384 ms 1672 KB Output is correct
3 Correct 581 ms 1776 KB Output is correct
4 Correct 629 ms 1564 KB Output is correct
5 Correct 861 ms 1776 KB Output is correct
6 Correct 698 ms 1732 KB Output is correct
7 Correct 734 ms 1628 KB Output is correct
8 Correct 519 ms 1584 KB Output is correct
9 Correct 67 ms 1416 KB Output is correct
10 Correct 989 ms 1604 KB Output is correct
11 Correct 1000 ms 1792 KB Output is correct
12 Correct 970 ms 1604 KB Output is correct
13 Correct 1245 ms 1892 KB Output is correct
14 Correct 710 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 1576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 246 ms 1100 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -