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;
long long s, a[5][100000];
void fail(){
cout << "NE";
exit(0);
}
int main(){
cin >> s;
if(s == 3) fail();
for(int i = 0; i < 4; i++){
for(int j = 0; j < s; j++) cin >> a[i][j];
}
for(int i = 0; i < s; i++){
if(a[0][i] == -1 && a[1][i] != -1) fail();
if(a[1][i] == -1 && a[0][i] != -1) fail();
if(a[0][i] == 0 && a[1][i] == 0) continue;
if(a[0][i] == s-1 && a[1][i] != 0) fail();
if(a[1][i] == s-1 && a[0][i] != 0) fail();
}
for(int i = 0; i < s; i++){
if(a[2][i] == -1 && a[3][i] != -1) fail();
if(a[3][i] == -1 && a[3][i] != -1) fail();
if(a[2][i] == -1 && a[3][i] == 0) continue;
if(a[2][i] == s-1 && a[3][i] != 0) fail();
if(a[3][i] == s-1 && a[2][i] != 0) fail();
}
cout << "DA";
}
# | 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... |