Submission #1095671

#TimeUsernameProblemLanguageResultExecution timeMemory
1095671idiotcomputercmp (balkan11_cmp)C++11
100 / 100
2100 ms96176 KiB
#include "cmp.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(x) (int) (x).size() int ch[6] = {1, 5, 22, 87, 344, 1369}; int pw[6] = {1,4,16,64,256,1024}; void remember(int value){ int s = 0; for (int i = 5; i >= 0; i--){ s += pw[5-i] * ((value/pw[i]) % 4); //cout << s << ','; bit_set(s+ch[5-i]); //cout << s+ch[5-i] << " "; value = value % pw[i]; } //cout << '\n'; } int compare(int value){ vector<int> res(6); vector<int> cbit(6); int s = 0; int x; //cout << value << ": "; for (int i = 5; i >= 0; i--){ s += pw[5-i] * ((value/pw[i])%4); res[5-i] = s; cbit[5-i] = (value/pw[i])%4; value = value % pw[i]; } /*for (int c : res) cout << c << " "; cout << '\n'; for (int c : cbit) cout <<c << " "; cout << '\n';*/ int n = sz(res); int l = -1; int r = n; while (r-l>1){ x = (l+r)/2; if (bit_get(res[x]+ch[x])) l = x; else r = x; } l++; if (l == n) return 0; if (cbit[l] == 0) return -1; if (cbit[l] == 3) return 1; if (cbit[l] == 1){ x = 0; if (l > 0) x = res[l-1]; if (bit_get(x+ch[l])) return 1; return -1; } x = 0; if (l > 0) x = res[l-1]; x += pw[l]*3; if (bit_get(x+ch[l])) return -1; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...