Submission #990368

# Submission time Handle Problem Language Result Execution time Memory
990368 2024-05-30T10:19:50 Z StefanSebez Toy Train (IOI17_train) C++14
27 / 100
1211 ms 1872 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
const int N=5050;
vector<int>E[N],E1[N];
vector<int>r;
bool task3was[N],task3was1[N];
void task3DFS(int u){
	task3was[u]=true;
	for(auto i:E[u]){
		if(!task3was[i]) task3DFS(i);
	}
}
void task3DFS1(int u){
	task3was1[u]=true;
	for(auto i:E1[u]){
		if(!task3was1[i]) task3DFS1(i);
	}
}
bool task4was[N],task4was1[N];
void task4DFS(int u){
	task4was[u]=true;
	for(auto i:E[u]){
		if(!task4was[i] && r[i]==0) task4DFS(i);
	}
}
void task4DFS1(int u){
	task4was1[u]=true;
	for(auto i:E1[u]){
		if(!task4was1[i] && r[i]==0) task4DFS1(i);
	}
}
void task4DFS2(int u){
	task4was[u]=true;
	for(auto i:E[u]){
		if(!task4was[i]) task4DFS2(i);
	}
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> rtemp, std::vector<int> u, std::vector<int> v) {
	std::vector<int> res(a.size());
	int n=a.size(),m=u.size();
	r=rtemp;
	for(int i=0;i<m;i++){
		E[u[i]].pb(v[i]);
		E1[v[i]].pb(u[i]);
	}
	bool subtask1=true;
	for(int i=0;i<m;i++) if(v[i]!=u[i] && v[i]!=u[i]+1) subtask1=false;
	bool subtask3=true;
	for(int i=0;i<n;i++) if(a[i]==0) subtask3=false;
	bool subtask4=true;
	for(int i=0;i<n;i++) if(a[i]==1) subtask4=false;
	if(subtask1){
		for(int i=0;i<n;i++){
			for(int j=i;j<n;){
				bool bul=false,bul2=false;
				for(auto k:E[j]){
					if(k==j+1) bul=true;
					if(k==j) bul2=true;
				}
				//printf("%i: %i %i\n",j,bul2,bul);
				if(a[j]==1){
					if(bul2 && r[j]==1) {res[i]=1;break;}
					else if(bul) j++;
					else {res[i]=0;break;}
				}
				else{
					if(bul2 && r[j]==0) {res[i]=0;break;}
					else if(bul) j++;
					else {res[i]=1;break;}
				}
			}
		}
	}
	else if(subtask3){
		bool ima[N]={false};
		for(int i=0;i<n;i++){
			if(r[i]==0) continue;
			task3DFS(i);
			task3DFS1(i);
			for(int j=0;j<n;j++){
				if(j!=i && task3was[j] && task3was1[j]) ima[i]=true;
				task3was[j]=task3was1[j]=false;
			}
			for(auto j:E[i]){
				if(j==i) ima[i]=true;
			}
		}
		for(int i=0;i<n;i++){
			task3DFS(i);
			res[i]=0;
			for(int j=0;j<n;j++){
				if(task3was[j] && ima[j]) res[i]=1;
				task3was[j]=task3was1[j]=false;
			}
		}
	}
	else if(subtask4){
		bool ima[N]={false};
		for(int i=0;i<n;i++){
			if(r[i]==1) continue;
			task4DFS(i);
			task4DFS1(i);
			for(int j=0;j<n;j++){
				if(j!=i && task4was[j] && task4was1[j]) ima[i]=true;
				task4was[j]=task4was1[j]=false;
			}
			for(auto j:E[i]){
				if(j==i) ima[i]=true;
			}
		}
		for(int i=0;i<n;i++){
			task4DFS2(i);
			res[i]=1;
			for(int j=0;j<n;j++){
				if(task4was[j] && ima[j]) res[i]=0;
				task4was[j]=task4was1[j]=false;
			}
		}
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1112 KB Output is correct
2 Correct 2 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 2 ms 1116 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 3 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 2 ms 1020 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 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 185 ms 1660 KB Output is correct
2 Correct 233 ms 1628 KB Output is correct
3 Correct 259 ms 1624 KB Output is correct
4 Correct 1114 ms 1368 KB Output is correct
5 Correct 661 ms 1552 KB Output is correct
6 Correct 478 ms 1616 KB Output is correct
7 Correct 805 ms 1512 KB Output is correct
8 Correct 264 ms 1372 KB Output is correct
9 Correct 255 ms 1372 KB Output is correct
10 Correct 315 ms 1368 KB Output is correct
11 Correct 281 ms 1368 KB Output is correct
12 Correct 61 ms 1372 KB Output is correct
13 Correct 720 ms 1576 KB Output is correct
14 Correct 779 ms 1584 KB Output is correct
15 Correct 723 ms 1372 KB Output is correct
16 Correct 758 ms 1372 KB Output is correct
17 Correct 744 ms 1580 KB Output is correct
18 Correct 508 ms 1316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 589 ms 1372 KB Output is correct
2 Correct 346 ms 1420 KB Output is correct
3 Correct 512 ms 1624 KB Output is correct
4 Correct 475 ms 1628 KB Output is correct
5 Correct 813 ms 1732 KB Output is correct
6 Correct 770 ms 1624 KB Output is correct
7 Correct 707 ms 1692 KB Output is correct
8 Correct 489 ms 1628 KB Output is correct
9 Correct 64 ms 1372 KB Output is correct
10 Correct 756 ms 1788 KB Output is correct
11 Correct 734 ms 1872 KB Output is correct
12 Correct 758 ms 1624 KB Output is correct
13 Correct 1211 ms 1624 KB Output is correct
14 Correct 695 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1368 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 1112 KB Output is correct
2 Correct 2 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 2 ms 1116 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 3 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 2 ms 1020 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Incorrect 0 ms 604 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -