This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,a[4][100005];
pair<int,int> b[100005];
int main()
{
cin>>n;
for(int i=0;i<4;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
for(int i=0;i<n;i++){
b[i].first=1e9;
b[i].second=-1;
}
for(int i=0;i<n;i++){
if(a[0][i]==-1&&a[1][i]!=-1){cout<<"NE"<<endl;return 0;}
if(a[1][i]==-1&&a[0][i]!=-1){cout<<"NE"<<endl;return 0;}
if(a[0][i]+a[1][i]>=n){cout<<"NE"<<endl;return 0;}
b[a[0][i]].first=min(b[a[0][i]].first,i);
b[a[0][i]].second=max(b[a[0][i]].second,i);
b[n-a[1][i]-1].first=min(b[n-1-a[1][i]].first,i);
b[n-1-a[1][i]].second=max(b[n-1-a[1][i]].second,i);
}
for(int i=0;i<n;i++){
if(a[2][i]==-1&&a[3][i]!=-1){cout<<"NE"<<endl;return 0;}
if(a[3][i]==-1&&a[2][i]!=-1){cout<<"NE"<<endl;return 0;}
if(a[2][i]+a[3][i]>=n){cout<<"NE"<<endl;return 0;}
if(b[i].first!=1e9){
if(a[2][i]!=b[i].first){cout<<"NE"<<endl;return 0;}
if(n-a[3][i]-1!=b[i].second){cout<<"NE"<<endl;return 0;}
}
}
cout<<"DA"<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |