Submission #927994

# Submission time Handle Problem Language Result Execution time Memory
927994 2024-02-15T16:25:59 Z Naser cmp (balkan11_cmp) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <unordered_map>
#define int long long
#define endl '\n'
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pii>
#define pb push_back
#define se second
#define fi first
#define all(x) x.begin(), x.end()
#define graph vector<vint>
using namespace std;
const int N = (int)3e5 + 69;
const int mod = 9999991;
const int naser = 3999, has_7 = 3662;
int INF = LLONG_MAX;
int power(int a, int bb) { int ans = 1;while (bb) { if (bb % 2) { ans *= a; }a *= a;bb /= 2; }return ans; }
int gcd(int a, int b) { if (b == 0)return a;return gcd(b, a % b); }

//int cnt = 0;
//int constant = 1111;
//int bits[10000];
//void bit_set(int add) {
//    cnt++;
//    bits[add] = 1;
//}
//int bit_get(int add) {
//    cnt++;
//    return bits[add];
//}
int base8(int x) {
    int ans = 0, p = 1;
    while (x) {
        ans += p * (x % 8);
        x /= 8;
        p *= 10;
    }
    return ans;
}
void remember(int a) {
    a = base8(a);
    vint prf(4);
    prf[0] = a;
    for (int i = 1; i < 4; i++) {
        prf[i] = a / power(10, i);
        for (int j = 0; j < i; j++) {
            prf[i] *= 10;
            prf[i] += 8;
        }
    }
    for (int i = 0; i < 4; i++) 
        bit_set(prf[i]+1);

}
int compare(int b) {
    b = base8(b);
    if (bit_get(b)+1)
        return 0;
    vint prf(4);
    prf[0] = b;
    for (int i = 1; i < 4; i++) {
        prf[i] = b / power(10, i);
        for (int j = 0; j < i; j++) {
            prf[i] *= 10;
            prf[i] += 8;
        }
    }
    int l = 0, r = 3;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        if (bit_get(prf[mid]+1))
            r = mid - 1;
        else
            l = mid;
    }
    int dig = l, base = power(10, dig);
    if (prf[dig] % (base * 10) == 8)
        return -1;
    if ((b/base)%10 > 3) {
        for (int i = (b / base) % 10 + 1; i < 8; i++) {
            if (bit_get(prf[dig] + (i - ((b / base) % 10)) * base)+1)
                return -1;
        }
        return 1;
    }
    else {
        for (int i = (b / base) % 10 - 1; i >= 0; i--) {
            if (bit_get(prf[dig] + (i - ((b / base) % 10)) * base)+1)
                return 1;
        }
        return -1;
    }
}
//int32_t main() {
//
//    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
//    int mx = 0;
//    for (int a = 0; a < 4096; a++) {
//        for (int b = 0; b < 4096; b++) {
//            cnt = 0;
//            memset(bits, 0, sizeof bits);
//            if (a == 16 && b == 8)
//                b = b;
//            remember(a);
//            int tmp = compare(b);
//            mx = max(mx, cnt);
//            if (a > b && tmp != -1)
//                return cout << "Wrong " << a << ' ' << b << ' ' << tmp << endl, 0;
//            if (a < b && tmp != 1)
//                return cout << "Wrong " << a << ' ' << b << ' ' << tmp << endl, 0;
//            if (a == b && tmp)
//                return cout << "Wrong " << a << ' ' << b << ' ' << tmp << endl, 0;
//            cout << a << ' ' << b << ' ' << tmp << endl;
//        }
//    }
//    cout << 1 + 9 * (21 - mx) << endl;
//}

Compilation message

cmp.cpp: In function 'void remember(long long int)':
cmp.cpp:53:9: error: 'bit_set' was not declared in this scope; did you mean 'tzset'?
   53 |         bit_set(prf[i]+1);
      |         ^~~~~~~
      |         tzset
cmp.cpp: In function 'long long int compare(long long int)':
cmp.cpp:58:9: error: 'bit_get' was not declared in this scope
   58 |     if (bit_get(b)+1)
      |         ^~~~~~~
cmp.cpp:72:13: error: 'bit_get' was not declared in this scope
   72 |         if (bit_get(prf[mid]+1))
      |             ^~~~~~~
cmp.cpp:82:17: error: 'bit_get' was not declared in this scope
   82 |             if (bit_get(prf[dig] + (i - ((b / base) % 10)) * base)+1)
      |                 ^~~~~~~
cmp.cpp:89:17: error: 'bit_get' was not declared in this scope
   89 |             if (bit_get(prf[dig] + (i - ((b / base) % 10)) * base)+1)
      |                 ^~~~~~~