Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int row[100005], column[100005];
  6.  
  7. int main(){
  8.    
  9.     ios_base::sync_with_stdio(false);
  10.     cin.tie(0);
  11.  
  12.     int n;
  13.     cin >> n;
  14.     for(int i = 0; i < 4; i++){
  15.         for(int j = 0; j < n; j++){
  16.             int inp;
  17.             cin >> inp;
  18.             if(i == 0){
  19.                 if(inp == -1){
  20.                     row[j] = -1;
  21.                     continue;
  22.                 }
  23.                 row[j] = 1;
  24.                 column[inp] = 1;
  25.             }
  26.             else if(i == 1){
  27.                 if(inp == -1){
  28.                     if(row[j] == 1) return cout << "NE",0;
  29.                     continue;
  30.                 }
  31.                 else if(row[j] == -1 || column[n - inp - 1] == -1) return cout << "NE",0;
  32.                 row[j] = 1;
  33.                 column[n - inp - 1] = 1;
  34.             }
  35.             else if(i == 2){
  36.                 if(inp == -1){
  37.                     if(column[j] == 1) return cout << "NE",0;
  38.                     continue;
  39.                 }
  40.                 else if(column[j] == -1 || row[inp] == -1) return cout << "NE",0;
  41.                 row[inp] = 1;
  42.                 column[j] = 1;
  43.             }
  44.             else if(i == 3){
  45.                 if(inp == -1){
  46.                     if(column[j] == 1) return cout << "NE",0;
  47.                     continue;
  48.                 }
  49.                 else if(column[j] == -1 || row[n - inp - 1] == -1) return cout << "NE",0;
  50.                 row[n - inp - 1] = 1;
  51.                 column[j] = 1;
  52.             }
  53.         }
  54.     }
  55.     cout << "DA";
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement