Submission #927703

# Submission time Handle Problem Language Result Execution time Memory
927703 2024-02-15T08:57:44 Z MuntherCarrot cmp (balkan11_cmp) C++17
0 / 100
693 ms 106832 KB
#include <bits/stdc++.h>
#include "cmp.h"
using namespace std;

// void bit_set(int add)
// int bit_get(int add);

void remember(int a){
    for(int i = 0; i < 4; i++){
        bit_set(a % 8 + i * 8 + 1);
        a /= 8;
    }
}
int compare(int b){
    int dig[4];
    for(int i = 0; i < 4; i++){
        dig[i] = b % 8;
        b /= 8;
    }
    int i = 3;
    for(; i >= 0; i--){
        int x = bit_get(dig[i] + i * 8 + 1);
        if(x == 0) break;
    }
    if(i == -1){
        return 0;
    }
    else{
        if(dig[i] == 7){
            return 1;
        }
        if(dig[i] == 6){
            int x = bit_get(7 + i * 8 + 1);
            return x == 1 ? -1 : 1;
        }
        if(dig[i] == 5){
            int x = 0;
            for(int j = dig[j] + 1; j < 8; j++){
                x |= bit_get(j + i * 8 + 1);
            }
            return x == 1 ? -1 : 1;
        }
        if(dig[i] == 4){
            int x = 0;
            for(int j = dig[j] + 1; j < 8; j++){
                x |= bit_get(j + i * 8 + 1);
            }
            return x == 1 ? -1 : 1;
        }
        if(dig[i] == 3){
            int x = 0;
            for(int j = 0; j < dig[j]; j++){
                x |= bit_get(j + i * 8 + 1);
            }
            return x == 1 ? 1 : -1;
        }
        if(dig[i] == 2){
            int x = 0;
            for(int j = 0; j < dig[j]; j++){
                x |= bit_get(j + i * 8 + 1);
            }
            return x == 1 ? 1 : -1;
        }
        if(dig[i] == 1){
            int x = bit_get(0 + i * 8 + 1);
            return x == 1 ? 1 : -1;
        }
        if(dig[i] == 0){
            return -1;
        }

    }
    return 0;
}

// by me

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:38:30: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |             for(int j = dig[j] + 1; j < 8; j++){
      |                         ~~~~~^
cmp.cpp:45:30: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |             for(int j = dig[j] + 1; j < 8; j++){
      |                         ~~~~~^
# Verdict Execution time Memory Grader output
1 Incorrect 693 ms 106832 KB ZERO POINTS: For a=1645 and b=3040, correct answer is 1, got -1