Submission #223547

# Submission time Handle Problem Language Result Execution time Memory
223547 2020-04-15T11:16:30 Z brcode cmp (balkan11_cmp) C++14
100 / 100
1932 ms 104952 KB
#include <iostream>
#include <bits/stdc++.h>
#include "cmp.h"

using namespace std;
int power[10];
int arr[8] = {1,4097,5200,6200,7200,8200,9200};
void remember(int n) {
    power[0] = 1;
    for(int i=1;i<=7;i++){
        power[i] = power[i-1]*4;
    }
    for (int i = 0;i<=5;i++){
       // cout<<((n >> (i * 2)))<<endl;
        bit_set(((n >> (i * 2)))+arr[i]);
    }
}
int compare(int n){
    int l = 0;
    int r = 5;
    int ans =-1;
    while(l<=r){
        int mid = (l+r)/2;
      //  cout<<(n >> (mid * 2))<<" "<<check[((n >> (mid * 2)))+arr[mid]]<<endl;
        if(bit_get(((n >> (mid * 2)))+arr[mid])){
            ans = mid;
            r=mid-1;
            
        }else{
            l=mid+1;
            
        }
    }
    if(ans == 0){
       
        return 0;
    }
    if(ans == -1){
        ans = 6;
    }
    l=0;
    r=3;
    int dig = ((n >> ((ans-1) * 2)))-(4*(n >> ((ans) * 2)));
    //cout<<123<<" "<<dig<<endl;
    if(dig == 3){
        return 1;
    }
    if(dig == 0){
        return -1;
    }
    if(dig == 1){
        if(bit_get(((4*(n >> ((ans) * 2)))+0)+arr[ans-1])){
            return 1;
        }else{
            return -1;
        }
    }
    if(dig == 2){
        if(bit_get(((4*(n >> ((ans) * 2)))+3)+arr[ans-1])){
            return -1;
        }else{
            return 1;
        }
    }
    
    
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 1932 ms 104952 KB Output is correct - maxAccess = 10, score = 100