답안 #253841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
253841 2020-07-28T21:39:29 Z fivefourthreeone 비교 (balkan11_cmp) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gp_hash_table<int, int> mp;
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
//write a as power of 4, binary search down and compare at the end;
/*bool stuff[4097][10241];
int idx1;
int idx2;
int num;
void bit_set(int a) {
    idx1++;
    stuff[num][a] = true;
}
int bit_get(int a) {
    idx2++;
    return stuff[num][a];
}*/
int fours[6] = {1, 4, 16, 64, 256, 1024};
void remember(int a) {
    owo(i, 0, 6) {
        bit_set(a);
        a/=4;
    }
}
int compare(int b) {
    int l = 0;
    int r = 5;
    while(l<r) {
        int mid = (l+r)/2;
        if(bit_get(b/fours[mid]))r = mid;
        else l = mid+1;
    }
    if(l==0)return 0;
    int curr = b/fours[l];
    int diff = (b/fours[l-1]-(4*curr));
    if(diff==0) {
        return -1;
    }else if(diff==3) {
        return 1;
    }else if(diff==1) {
        if(bit_get(curr*fours[l]))return 1;
        else return -1;
    }else {
        if(bit_get(curr*fours[l]+3))return -1;
        else return 1;
    }
}
/*int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin>>n>>m;
    remember(n);
    cout<<compare(m)<<" "<<idx1<<" "<<idx2<<"\n";
    return 0;
}
*/

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:41:9: error: 'bit_set' was not declared in this scope
         bit_set(a);
         ^~~~~~~
cmp.cpp:41:9: note: suggested alternative: 'tzset'
         bit_set(a);
         ^~~~~~~
         tzset
cmp.cpp: In function 'int compare(int)':
cmp.cpp:50:12: error: 'bit_get' was not declared in this scope
         if(bit_get(b/fours[mid]))r = mid;
            ^~~~~~~
cmp.cpp:61:12: error: 'bit_get' was not declared in this scope
         if(bit_get(curr*fours[l]))return 1;
            ^~~~~~~
cmp.cpp:64:12: error: 'bit_get' was not declared in this scope
         if(bit_get(curr*fours[l]+3))return -1;
            ^~~~~~~
cmp.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^