답안 #39464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39464 2018-01-15T16:01:22 Z smu201111192 비교 (balkan11_cmp) C++14
0 / 100
956 ms 99660 KB
#include "cmp.h"
void remember(int n){
    int a[4]; int pos = 3;
    while(pos >= 0){
        a[pos--] = (n % 8); n/=8;
    }
    int cur = 1;
    for(int i=0;i<4;i++){
        cur = cur * 8 + a[i];
        bit_set(cur);
    }
}
int compare(int b) {
    int n = b;
    int a[4]; int pos = 3;
    while(pos >= 0){
        a[pos--] = (n % 8); n/=8;
    }
    int cur = 1; int i = 0;
    for(;i<4;i++){
        cur = cur * 8 + a[i];
        int bit = bit_get(cur);
        if(!bit) break;
    }
    if(i == 4)return 0;
    cur /= 8;
    int chk = -1;
    if(a[i] == 0)return -1;
    if(a[i] == 7)return 1;
    if(a[i] <= 3){
        for(int k = 1 ; k < a[i]; k ++){
            int bit = bit_get(cur * 8 + k);
            if(bit == 1) chk = k;
            
        }
        if(chk == -1) return -1;
        else return 1;
    }
    else{
        for(int k = a[i] + 1; k <= 7; k++){
            int bit = bit_get(cur * 8 + k);
            if(bit = 1) chk=k;
        
        }
        if(chk == -1) return 1;
        else return -1;
    }
    return 1;
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:42:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
             if(bit = 1) chk=k;
                ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 956 ms 99660 KB ZERO POINTS: For a=3040 and b=3318, correct answer is 1, got -1