# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566818 | 2022-05-22T22:02:46 Z | Deepesson | 비교 (balkan11_cmp) | C++17 | 3927 ms | 102196 KB |
#include <bits/stdc++.h> #include "cmp.h" void bit_set(int addr); int bit_get(int addr); bool marcas[15]={}; void remember(int n) { std::vector<int> vec; while(n){ vec.push_back(n%4); n/=4; } while(vec.size()<6) vec.push_back(0); std::reverse(vec.begin(),vec.end()); int base=1; for(int i=0;i!=vec.size();++i){ base*=4; base+=vec[i]; bit_set(base); } } int compare(int b) { std::vector<int> vec; while(b){ vec.push_back(b%4); b/=4; } while(vec.size()<6) vec.push_back(0); std::reverse(vec.begin(),vec.end()); int l=0,r=6; while(l<r){ int m = (l+r+1)/2; int base=1; for(int i=0;i<m;++i){ base*=4; base+=vec[i]; } int x = bit_get(base); if(x){ l=m; }else r=m-1; } ///Sao iguais if(l==6){ return 0; } ///Eh maior if(vec[l]==3){ return 1; } ///Eh menor if(!vec[l]){ return -1; } int base=1; for(int i=0;i<l;++i){ base*=4; base+=vec[i]; } ///Checar o zero if(vec[l]==1) { base*=4; if(bit_get(base)){ return 1; }else return -1; }else { base*=4;base+=3; if(bit_get(base)){ return -1; }else return 1; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3927 ms | 102196 KB | Output is correct - maxAccess = 10, score = 100 |