Submission #359799

# Submission time Handle Problem Language Result Execution time Memory
359799 2021-01-27T08:03:20 Z kshitij_sodani cmp (balkan11_cmp) C++14
73 / 100
5075 ms 82556 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back

#define endl '\n'

#include "cmp.h"

void remember(int n) {
  //edit this
	int xx=0;
	for(int i=0;i<12;i++){
		if(n&(1<<i)){
			xx+=(1<<(11-i));
		}
	}
	int nn=n;
	n=xx;

	int ind=1;

	for(int i=0;i<12;i+=2){
			int cur=ind;
			if(n&(1<<i)){
				cur+=2;
			}
			if(n&(1<<(i+1))){
				cur+=1;
			}
			bit_set(cur);

		ind+=4;	
	}
/*	if(co<=6){
		for(int i=0;i<12;i++){
			if(n&(1<<i)){
				bit_set(i+2);
			}
			else{

			}
		}
	}
	else{
		bit_set(1);
		for(int i=0;i<12;i++){
			if(n&(1<<i)){
			}
			else{
				bit_set(i+2);
			}
		}
	}*/

}
bool check(int ind,int b){
	int ask=0;
	for(int i=0;i<ind;i++){
		ask+=(b&(1<<i));
	}
	for(int i=0;i<ind-1;i++){
		ask+=(1<<(i+1));
	}
	return bit_get(ask+1);
}
int compare(int b) {
  //edit this
	int xx=0;
	for(int i=0;i<12;i++){
		if(b&(1<<i)){
			xx+=(1<<(11-i));
		}
	}
	int bb=b;
	b=xx;
	int ind=1;
	for(int i=0;i<12;i+=2){
		int ac=0;
		if(b&(1<<i)){
			ac=2;
		}
		int bc=0;
		if(b&(1<<(i+1))){
			bc=1;
		}
		int su=ac+bc;
		if(bit_get(ind+su)==0){
			/*if(bb==1822){
				cout<<i<<endl;
				cout<<ac<<":"<<bc<<endl;
			}*/
			vector<int> cc;
			vector<int> dd;
			for(int j=1;j<4;j++){
				if((su^j)<su){
					cc.pb(su^j);
				}
				else{
					dd.pb(su^j);
				}
			}
			if(cc.size()<=dd.size()){
				int st=-1;	
				for(auto j:cc){
					if(bit_get(ind+j)){
						st=1;
						break;
					}
				}
				return st;
			}
			else{
				int st=1;	
				for(auto j:dd){
					if(bit_get(ind+j)){
						st=-1;
						break;
					}
				}
				return st;
			}
/*
			if(bit_get(ind+(ac^2)+(bc))==1){

				int cur=(ac^2)+bc;
				if(cur<ac+bc){
					return 1;
				}
				return -1;
			}
			else if(bit_get(ind+(ac^2)+(bc^1))==1){

				int cur=(ac^2)+(bc^1);
				if(cur<ac+bc){
					return 1;
				}
				return -1;
			}
			else{
				int cur=(ac)+(bc^1);
				if(cur<ac+bc){
					return 1;
				}
				return -1;
			}*/
		}
		ind+=4;
	}
	return 0;
/*	int num=0;
	int ind=0;
	for(int i=3;i>=0;i--){
		if((ind+(1<<i))>12){
			continue;
		}
		if(check(ind+(1<<i),b)){
			ind+=(1<<i);
		}
	}*/
	/*if(bb==1268){
		cout<<ind<<endl;
	}*/
	if(ind==12){
		return 0;
	}
	if(b&(1<<ind)){
		return 1;
	}
	return -1;
	/*for(int i=2;i<=13;i++){
		if(bit_get(i)){
			num+=(1<<(i-2));
		}
	}
	if(bit_get(1)){
		num^=4095;
	}
	if(num>b){
		return -1;
	}
	if(num==b){
		return 0; 
	}*/
	return 1;
}

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:20:6: warning: unused variable 'nn' [-Wunused-variable]
   20 |  int nn=n;
      |      ^~
cmp.cpp: In function 'int compare(int)':
cmp.cpp:77:6: warning: unused variable 'bb' [-Wunused-variable]
   77 |  int bb=b;
      |      ^~
# Verdict Execution time Memory Grader output
1 Partially correct 5075 ms 82556 KB Output is partially correct - maxAccess = 13, score = 73