Submission #701705

#TimeUsernameProblemLanguageResultExecution timeMemory
701705alanlKocka (COCI18_kocka)C++14
14 / 70
30 ms2660 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define s second #define rep(X, a,b) for(int X=a;X<b;++X) #define ALL(a) (a).begin(), (a).end() #define SZ(a) (int)(a).size() #define NL "\n" using namespace std; typedef pair<long long,long long> pll; typedef pair<int,int> pii; typedef long long ll; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; } template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){ for(const auto &a:p) os << a << " "; os << "\n"; return os; } int val[100010][4]; int col[100010][2]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; rep(k,0,4) rep(i,0,n) cin>>val[i][k]; memset(&col[0][0], -1, sizeof(col)); rep(i,0,n){ if(val[i][0]==-1 && val[i][1]==-1) continue; if((val[i][0]==-1 && val[i][1]!=-1) || (val[i][0]!=-1 && val[i][1]==-1)){ cout<<"NE\n"; return 0; } if(val[i][0]+val[i][1]<n){ if(col[val[i][0]][0]==-1) col[val[i][0]][0]=i, col[val[i][0]][1]=i; else col[val[i][0]][1]=i; if(col[n-1-val[i][1]][0]==-1) col[n-1-val[i][1]][0]=i, col[n-1-val[i][1]][1]=i; else col[n-1-val[i][1]][1]=i; }//fix else{ cout<<"NE\n"; return 0; } } rep(i,0,n){ if(val[i][2]==-1 && val[i][3]==-1){ if(col[i][0]==-1) continue; else{ cout<<"NE\n"; return 0; } } if((val[i][2]==-1 && val[i][3]!=-1) || (val[i][2]!=-1 && val[i][3]==-1)){ cout<<"NE\n"; return 0; } if(col[i][0]==-1){ cout<<"NE\n"; return 0; } if(val[i][2]+val[i][3]>=n-(col[i][1]-col[i][0])){ cout<<"NE\n"; return 0; } } memset(&col[0][0], -1, sizeof(col)); rep(i,0,n){ if(val[i][2]==-1 && val[i][3]==-1) continue; if((val[i][2]==-1 && val[i][3]!=-1) || (val[i][2]!=-1 && val[i][3]==-1)){ cout<<"NE\n"; return 0; } if(val[i][2]+val[i][3]<n){ if(col[val[i][2]][0]==-1) col[val[i][2]][0]=i, col[val[i][2]][1]=i; else col[val[i][2]][1]=i; if(col[n-1-val[i][3]][0]==-1) col[n-1-val[i][3]][0]=i, col[n-1-val[i][3]][1]=i; else col[n-1-val[i][3]][1]=i; }//fix else{ cout<<"NE\n"; return 0; } } rep(i,0,n){ if(val[i][0]==-1 && val[i][1]==-1){ if(col[i][0]==-1) continue; else{ cout<<"NE\n"; return 0; } } if((val[i][0]==-1 && val[i][1]!=-1) || (val[i][0]!=-1 && val[i][1]==-1)){ cout<<"NE\n"; return 0; } if(col[i][0]==-1){ cout<<"NE\n"; return 0; } if(val[i][0]+val[i][1]>=n-(col[i][1]-col[i][0])){ // cout<<val[i][0]+val[i][1]<<" "<<col[i][1]-col[i][0]<<" "<<i<<NL; cout<<"NE\n"; return 0; } } cout<<"DA\n"; }
#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...