Submission #166935

# Submission time Handle Problem Language Result Execution time Memory
166935 2019-12-04T17:21:37 Z muhi1112 Kocka (COCI18_kocka) C++17
0 / 70
45 ms 4008 KB
#include <bits/stdc++.h>
using namespace std;

#define f0 first
#define s2 second
#define mp make_pair
#define pb push_back
#define ll long long 
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=1e5+5;

int n,left1[N],right1[N],top[N],bottom[N];

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>left1[i];
	}
	for(int i=0;i<n;i++){
		cin>>right1[i];
	}
	for(int i=0;i<n;i++){
		cin>>top[i];
	}
	for(int i=0;i<n;i++){
		cin>>bottom[i];
	}
	for(int i=0;i<n;i++){
		if(left1[i]==-1){
			if(right1[i]!=-1 || top[0]==i || bottom[0]==n-i-1){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(left1[i]>=0){
			if(top[left1[i]]>i || bottom[left1[i]]>i || right1[i]+left1[i]>=n){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(right1[i]==-1){
			if(left1[i]!=-1 || top[n-1]==i || bottom[n-1]==n-i-1){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(right1[i]>=0){
			if(top[n-right1[i]-1]>i || bottom[n-right1[i]-1]>i || right1[i]+left1[i]>=n){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(top[i]==-1){
			if(bottom[i]!=-1 || left1[0]==i || right1[0]==i){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(top[i]>=0){
			if(top[i]+bottom[i]>=n || left1[top[i]]>i || right1[top[i]]>n-i-1){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(bottom[i]==-1){
			if(top[i]!=-1 || left1[n-1]==i || right1[n-1]==i){
				cout<<"NE"<<endl;
				return 0;
			}
		}
		if(bottom[i]>=0){
			if(top[i]+bottom[i]>=n || left1[n-bottom[i]-1]>i || right1[n-bottom[i]-1]>n-i-1){
				//cout<<i<<" "<<left1[n-bottom[i]-1]<<" "<<right1[n-bottom[i]-1];
				cout<<"NE"<<endl;
				return 0;
			}
		}
	}
	cout<<"DA"<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 3832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 4008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 3928 KB Output isn't correct
2 Halted 0 ms 0 KB -