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>
using namespace std;
typedef long long ll;
#define int ll
int n;
int l[100005],r[100005],u[100005],d[100005];
set<int> s[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){
s[u[i]+1].insert(i);
s[n-d[i]].insert(i);
}
}
for(int i=1;i<=n;i++){
if(l[i]==-1){
if(!s[i].empty()){
cout << "NE" << "\n";
return 0;
}
}
else{
if(s[i].empty()){
cout << "NE" << "\n";
return 0;
}
int x = *s[i].begin(), y = *prev(s[i].end());
if(x!=l[i]+1 or y!=n-r[i]){
cout << "NE" << "\n";
return 0;
}
}
}
cout << "DA" << "\n";
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... |