Submission #890288

#TimeUsernameProblemLanguageResultExecution timeMemory
890288pccKocka (COCI18_kocka)C++14
70 / 70
90 ms16984 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 1e5+10; vector<int> row[mxn],col[mxn]; int arr[4][mxn]; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin>>n; for(int i = 0;i<4;i++)for(int j = 1;j<=n;j++)cin>>arr[i][j]; bool flag = true; for(int i = 1;i<=n;i++){ int neg = (arr[0][i] == -1?1:0)+(arr[1][i] == -1?1:0); if(neg&1)flag = false; neg = (arr[2][i] == -1?1:0)+(arr[3][i] == -1?1:0); if(neg&1)flag = false; if(arr[0][i]+arr[1][i]>=n)flag = false; if(arr[2][i]+arr[3][i]>=n)flag = false; row[i].push_back(arr[0][i]+1); row[i].push_back(n-arr[1][i]); col[arr[0][i]+1].push_back(i); col[n-arr[1][i]].push_back(i); col[i].push_back(arr[2][i]+1); col[i].push_back(n-arr[3][i]); row[arr[2][i]+1].push_back(i); row[n-arr[3][i]].push_back(i); } for(int i = 1;i<=n;i++){ sort(row[i].begin(),row[i].end()); sort(col[i].begin(),col[i].end()); } for(int i = 1;i<=n;i++){ if(row[i][0] != arr[0][i]+1)flag = false; if(row[i].back() != n-arr[1][i])flag = false; if(col[i][0] != arr[2][i]+1)flag = false; if(col[i].back() != n-arr[3][i])flag = false; } cout<<(flag?"DA":"NE"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...