# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
927873 | 2024-02-15T13:09:39 Z | MrM7md | cmp (balkan11_cmp) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "cmp.h" using namespace std; void remember(int n) { int a[4]; for(int i=3;i>=0;i--){ a[3]=n%8; n/=8; } int cur=0,mlt=1000; for(int i=0;i<4;i++){ cur+=a[i]*mlt; mlt/=10; bit_set(cur); } } int compare(int b) { int a[4]; vector<int>v; for(int i=3;i>=0;i--){ a[3]=b%8; b/=8; } int cur=0,mlt=1000; for(int i=0;i<4;i++){ cur+=a[i]*mlt; mlt/=10; v.pb(cur); } int l=0,r=3; int ans=-1; while(l<=r){ md=(l+r)/2; int get=bit_get(v[md]); if(get){ l=md+1; if(md==3){ ans=0; } } else{ r=md-1; } } int m; if(l==0)m=1000; else if(l==1)m=100; else if(l==2)m=10; else m=1; if(a[l]<=3){ bool bl=0; for(int i=a[i]-1;i>=0;i--){ v[i]-=m; if(bit_get(v[i]))bl=1; } if(bl)ans=1; else if(ans==-1)ans=-1; } else{ bool bl=0; for(int i=a[i]+1;i<=7;i++){ v[i]+=m; if(bit_get(v[i]))bl=1; } if(bl)ans=-1; else if(ans==-1)ans=1; } return ans; }