Submission #568884

#TimeUsernameProblemLanguageResultExecution timeMemory
568884Jomnoicmp (balkan11_cmp)C++17
100 / 100
3359 ms102200 KiB
#include <bits/stdc++.h> #include "cmp.h" using namespace std; void remember(int n) { vector <int> digits; while(n > 0) { digits.push_back(n % 4); n /= 4; } while(digits.size() < 6) { digits.push_back(0); } reverse(digits.begin(), digits.end()); int base4 = 1; for(int i = 0; i < 6; i++) { base4 *= 4; base4 += digits[i]; bit_set(base4); } } int compare(int b) { vector <int> digits; while(b > 0) { digits.push_back(b % 4); b /= 4; } while(digits.size() < 6) { digits.push_back(0); } reverse(digits.begin(), digits.end()); int base4; int l = 0, r = 5, len = 0; while(l <= r) { int mid = (l + r) / 2; base4 = 1; for(int i = 0; i <= mid; i++) { base4 *= 4; base4 += digits[i]; } if(bit_get(base4)) { l = mid + 1; len = mid + 1; } else { r = mid - 1; } } if(len == 6) { return 0; } base4 = 1; for(int i = 0; i < len; i++) { base4 *= 4; base4 += digits[i]; } if(digits[len] >= 2) { base4 *= 4; base4 += 3; if(bit_get(base4)) { return -1; } return 1; } else { base4 *= 4; if(bit_get(base4)) { return 1; } return -1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...