#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
4 ms |
532 KB |
Output is correct |
6 |
Correct |
3 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
536 KB |
Output is correct |
2 |
Incorrect |
3 ms |
536 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
130 ms |
2804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
153 ms |
2868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
134 ms |
2984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |