Submission #648723

#TimeUsernameProblemLanguageResultExecution timeMemory
648723Johanncmp (balkan11_cmp)C++14
100 / 100
2461 ms82504 KiB
#include "cmp.h" #include "bits/stdc++.h" using namespace std; typedef vector<int> vi; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() vi bases = {6, 8, 10, 12}; vi getDig(int x) { vi ans(sz(bases), 0); for (int i = 0; i < sz(bases); ++i) { ans[i] = x % bases[i]; x /= bases[i]; } return ans; } int addr(int pos, int digit) { return digit * sz(bases) + pos + 1; } void print(vi &digits) { for (int d : digits) printf("%d ", d); printf("\n"); } void remember(int n) { vi digits = getDig(n); // print(ternary); for (int i = 0; i < sz(digits); ++i) bit_set(addr(i, digits[i])); } int compare(int b) { vi digits = getDig(b); // print(ternary); for (int i = sz(digits) - 1; i >= 0; --i) { if (bit_get(addr(i, digits[i]))) continue; if (digits[i] < bases[i] - digits[i]) { // untere Hälfte checken... for (int d = 0; d < digits[i]; ++d) { if (bit_get(addr(i, d))) return 1; } return -1; } else { for (int d = bases[i] - 1; d > digits[i]; --d) { if (bit_get(addr(i, d))) return -1; } return 1; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...