Submission #926912

# Submission time Handle Problem Language Result Execution time Memory
926912 2024-02-14T04:19:21 Z HD1 Kocka (COCI18_kocka) C++17
14 / 70
82 ms 5852 KB
//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

kocka.cpp: In function 'void solve()':
kocka.cpp:87:9: warning: the address of 'bool die()' will never be NULL [-Waddress]
   87 |     if(!die){
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 5820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 5852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 5816 KB Output isn't correct
2 Halted 0 ms 0 KB -