답안 #990365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990365 2024-05-30T10:17:04 Z StefanSebez 장난감 기차 (IOI17_train) C++14
16 / 100
1086 ms 1652 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);
	}
}
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++){
			task4DFS(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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1112 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 2 ms 1116 KB Output is correct
4 Correct 2 ms 1116 KB Output is correct
5 Correct 2 ms 1140 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 3 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 1652 KB Output is correct
2 Correct 223 ms 1628 KB Output is correct
3 Correct 269 ms 1640 KB Output is correct
4 Correct 1086 ms 1368 KB Output is correct
5 Correct 647 ms 1372 KB Output is correct
6 Correct 494 ms 1372 KB Output is correct
7 Correct 801 ms 1512 KB Output is correct
8 Correct 263 ms 1368 KB Output is correct
9 Correct 225 ms 1368 KB Output is correct
10 Correct 332 ms 1372 KB Output is correct
11 Correct 290 ms 1372 KB Output is correct
12 Correct 60 ms 1368 KB Output is correct
13 Correct 707 ms 1368 KB Output is correct
14 Correct 735 ms 1372 KB Output is correct
15 Correct 735 ms 1584 KB Output is correct
16 Correct 692 ms 1588 KB Output is correct
17 Correct 685 ms 1368 KB Output is correct
18 Correct 508 ms 1316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 1368 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1112 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 2 ms 1116 KB Output is correct
4 Correct 2 ms 1116 KB Output is correct
5 Correct 2 ms 1140 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 3 ms 1116 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 -