답안 #223535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223535 2020-04-15T11:03:39 Z brcode 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int power[10];
int arr[8] = {0,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]) = true;
    }
}
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;
 
    
    bool seen = false;
    for(int i=0;i<3;i++){
        if(i==dig){
            seen=true;
            continue;
            
        }
        //cout<<<<endl;
        if(i==2 && !seen){
            return 1;
        }
        if(bit_get(((4*(n >> ((ans) * 2)))+i)+arr[ans-1])){
            if(seen){
                return -1;
            }else{
                return 1;
            }
        }
    }
    return -1;
    
}

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:14:9: error: 'bit_set' was not declared in this scope
         bit_set(((n >> (i * 2)))+arr[i]) = true;
         ^~~~~~~
cmp.cpp:14:9: note: suggested alternative: 'sigset'
         bit_set(((n >> (i * 2)))+arr[i]) = true;
         ^~~~~~~
         sigset
cmp.cpp: In function 'int compare(int)':
cmp.cpp:24:12: error: 'bit_get' was not declared in this scope
         if(bit_get(((n >> (mid * 2)))+arr[mid])){
            ^~~~~~~
cmp.cpp:57:12: error: 'bit_get' was not declared in this scope
         if(bit_get(((4*(n >> ((ans) * 2)))+i)+arr[ans-1])){
            ^~~~~~~