Submission #778159

# Submission time Handle Problem Language Result Execution time Memory
778159 2023-07-10T06:55:23 Z vjudge1 Kocka (COCI18_kocka) C++17
0 / 70
30 ms 3600 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 100001
#define f first
#define s second
int main(){
	lalala;
	int n;cin>>n;
	int arr[n][4],asa[n][2],yan[n][2];
	int yes=0;
	memset(yan,-1,sizeof(yan));
	memset(asa,-1,sizeof(asa));
	for(int uwu=0;uwu<4;uwu++){
		for(int i=0;i<n;i++){
			cin>>arr[i][uwu];
			if(arr[i][uwu]==-1)continue;
			if(uwu==0){
				yan[i][0]=arr[i][uwu];
				if(asa[arr[i][uwu]][0]==-1)asa[arr[i][uwu]][0]=i;
			}
			if(uwu==1){
				yan[i][1]=n-arr[i][uwu]-1;
				asa[n-arr[i][uwu]-1][1]=i;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(arr[i][0]+arr[i][1]>n-1){
			yes=1;break;
		}
		if(arr[i][2]+arr[i][3]>n-1){
			yes=1;break;
		}
	}
	if(yes){
		cout<<"NE"<<endl;return 0;
	}
	for(int i=0;i<n;i++){
		int yer=arr[i][2];
		if(asa[i][0]==yer||asa[i][1]==yer)continue;
		if(asa[i][0]==-1||asa[i][1]==-1){
			yes=1;
			break;
		}
		if(yer==-1){yes=1;break;}
		if(asa[i][0]<yer&&asa[i][1]>yer){
			if(yan[yer][0]==-1||yan[yer][1]==-1){
				yes=1;break;
			}
			if(yan[yer][0]<=i&&yan[yer][1]>=i){
				continue;
			}
		}
		yes=1;
		break;
	}

	for(int i=0;i<n;i++){
		int yer=arr[i][3];
		if(asa[i][0]==0&&asa[i][1]==-1&&yer==-1)continue;
		yer=n-yer-1;
		if(asa[i][0]==yer||asa[i][1]==yer)continue;
		if(asa[i][0]==-1||asa[i][1]==-1){
			yes=1;
			break;
		}
		if(yer==-1){yes=1;break;}
		if(asa[i][0]<yer&&asa[i][1]>yer){
			if(yan[yer][0]==-1||yan[yer][1]==-1){
				yes=1;break;
			}
			if(yan[yer][0]<=i&&yan[yer][1]>=i){
				continue;
			}
		}
		yes=1;
		break;
	}
	if(yes)cout<<"NE"<<endl;
	else cout<<"DA"<<endl;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3524 KB Output isn't correct
2 Halted 0 ms 0 KB -