Submission #722746

# Submission time Handle Problem Language Result Execution time Memory
722746 2023-04-12T19:06:19 Z tvladm2009 cmp (balkan11_cmp) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "cmp.h"

using namespace std;

typedef long long ll;

int v[] = {0, 10, 10, 8, 6};
int p[] = {0, 4800, 480, 48, 6, 1};
int t[] = {0, 1, 11, 21, 29};

int remember(int a) {
    for (int i = 4; i >= 1; i--) {
        int x = (a / p[i + 1]) % v[i];
        bit_set(x + t[i]);
    }
}

int compare(int b) {
    int i = 1;
    for (; i <= 4; i++) {
        int x = (b / p[i + 1]) % v[i];
        if (bit_get(x + t[i]) == 0) {
            break;
        }
    }
    if (i == 5) {
        return 0;
    }
    int pos = t[i];
    int l = 0, r = v[i] - 1;
    if (x - l < r - x) {
        for (int i = l; i < x; i++) {
            if (bit_get(i + pos) == 1) {
                return 1;
            }
        }
        return -1;
    } else {
        for (int i = r; i > x; i--) {
            if (bit_get(i + pos) == 1) {
                return -1;
            }
        }
        return 1;
    }
}


Compilation message

cmp.cpp:12:5: error: ambiguating new declaration of 'int remember(int)'
   12 | int remember(int a) {
      |     ^~~~~~~~
In file included from cmp.cpp:2:
cmp.h:1:6: note: old declaration 'void remember(int)'
    1 | void remember(int a);
      |      ^~~~~~~~
cmp.cpp: In function 'int remember(int)':
cmp.cpp:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
cmp.cpp: In function 'int compare(int)':
cmp.cpp:32:9: error: 'x' was not declared in this scope
   32 |     if (x - l < r - x) {
      |         ^
cmp.cpp:31:16: warning: control reaches end of non-void function [-Wreturn-type]
   31 |     int l = 0, r = v[i] - 1;
      |                ^