| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 926912 | HD1 | Kocka (COCI18_kocka) | C++17 | 82 ms | 5852 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//we all are lost trying to be someone 
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef unsigned long long ll;
const ll MAX=1000000;
const int inf=1e7;
vector<int> A[5];
int n;
set<int> comodin;
bool check(){
	comodin.clear();
	vector<int>U=A[2];
	vector<int>L=A[0];
	vector<pair<int,int>> first;
	for(int i=0; i<n; i++){
		first.pb({L[i],i});
	}
	sort(all(first));
	//for(auto it:first){
		//cout<<'('<<it.ff<<','<<it.ss<<')'<<' ';
	//}
	//cout<<'\n';
	int j=0;
	for(int i=0; i<n; i++){
		while(j<n and first[j].ff<i){
			j++;
		}
		int primer=first[j].ss;
		if(first[j].ff!=i)primer=inf;
		//cout<<primer<<'\n';
		if(primer==U[i]){
			comodin.insert(U[i]);
			continue;
		}
		if(primer>U[i]){
			if(comodin.count(U[i]))continue;
			else return false;
		}
		else return false;
	}
	return true;
}
void turnleft(){
	vector<int> x=A[0];
	vector<int> y=A[1];
	A[0]=A[2];
	reverse(all(A[0]));
	A[1]=A[3];
	reverse(all(A[1]));
	A[2]=y;
	A[3]=x;
	//for(int i=0; i<4; i++){
    	//for(int j=0; j<n; j++){
    	//	cout<<A[i][j]<<' ';
    	//}
    	//cout<<'\n';
    //}
	return;
}
bool die(){
	for(int i=0; i<n; i++){
		if(A[0][i]==inf and A[1][i]==inf) continue;
		if(A[0][i]+A[1][i]>=n)return false;
	}
	for(int i=0; i<n; i++){
		if(A[2][i]==inf and A[3][i]==inf) continue;
		if(A[2][i]+A[3][i]>=n)return false;
	}
	return true;
}
void solve(){
    int a;
    cin>>n;
    for(int i=0; i<4; i++){
    	for(int j=0; j<n; j++){
    		cin>>a;
    		if(a == -1) a=inf;
    		A[i].pb(a);
    	}
    }
    if(!die){
    	cout<<"NE"<<'\n';
    	return;
    }
    for(int i=0; i<4; i++){
    	if(!check()){
    		cout<<"NE"<<'\n';
    		return;
    	}
    	turnleft();
    }
    cout<<"DA"<<'\n';
    return;
}
int main(){
    solve();
    return 0;
}
Compilation message (stderr)
| # | 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... | ||||
