답안 #990361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990361 2024-05-30T09:59:45 Z StefanSebez 장난감 기차 (IOI17_train) C++14
5 / 100
1090 ms 1740 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];
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);
	}
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	std::vector<int> res(a.size());
	int n=a.size(),m=u.size();
	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(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){

	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 1116 KB Output is correct
5 Correct 4 ms 1116 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 2 ms 1116 KB Output is correct
10 Correct 2 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 203 ms 1628 KB Output is correct
2 Correct 222 ms 1624 KB Output is correct
3 Correct 267 ms 1628 KB Output is correct
4 Correct 1090 ms 1552 KB Output is correct
5 Correct 626 ms 1740 KB Output is correct
6 Correct 481 ms 1628 KB Output is correct
7 Correct 862 ms 1696 KB Output is correct
8 Correct 261 ms 1628 KB Output is correct
9 Correct 239 ms 1628 KB Output is correct
10 Correct 332 ms 1624 KB Output is correct
11 Incorrect 284 ms 1636 KB 3rd lines differ - on the 89th token, expected: '1', found: '0'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1112 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1372 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 2 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 2 ms 1116 KB Output is correct
5 Correct 4 ms 1116 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 2 ms 1116 KB Output is correct
10 Correct 2 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 -