#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n;
int l[100005],r[100005],u[100005],d[100005];
map<int,bool> mp[100005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++){
cin >> l[i];
}
for(int i=1;i<=n;i++){
cin >> r[i];
}
for(int i=1;i<=n;i++){
cin >> u[i];
}
for(int i=1;i<=n;i++){
cin >> d[i];
}
for(int i=1;i<=n;i++){
if(l[i]==-1 and r[i]==-1){
continue;
}
else if(l[i]==-1 or r[i]==-1){
cout << "NE" << "\n";
return 0;
}
else if(l[i]+r[i]>=n){
cout << "NE" << "\n";
return 0;
}
}
for(int i=1;i<=n;i++){
if(u[i]==-1 and d[i]==-1){
continue;
}
else if(u[i]==-1 or d[i]==-1){
cout << "NE" << "\n";
return 0;
}
else if(u[i]+d[i]>=n){
cout << "NE" << "\n";
return 0;
}
}
for(int i=1;i<=n;i++){
if(u[i]!=-1){
mp[u[i]+1][i] = true;
mp[n-d[i]][i] = true;
}
}
for(int i=1;i<=n;i++){
if(l[i]==-1){
if(!mp[i].empty()){
cout << "NE" << "\n";
return 0;
}
}
else{
if(mp[i].empty()){
cout << "NE" << "\n";
return 0;
}
int x = mp[i].begin()->first, y = prev(mp[i].end())->first;
if(x!=l[i]+1 or y!=n-r[i]){
cout << "NE" << "\n";
return 0;
}
}
}
cout << "DA" << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5048 KB |
Output is correct |
2 |
Correct |
4 ms |
5076 KB |
Output is correct |
3 |
Correct |
4 ms |
5040 KB |
Output is correct |
4 |
Correct |
3 ms |
5036 KB |
Output is correct |
5 |
Correct |
4 ms |
5040 KB |
Output is correct |
6 |
Correct |
3 ms |
5020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5048 KB |
Output is correct |
2 |
Incorrect |
3 ms |
5204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
15572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
95 ms |
22588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
15496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |