답안 #253843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
253843 2020-07-28T21:41:14 Z fivefourthreeone 비교 (balkan11_cmp) C++17
0 / 100
1041 ms 102264 KB
#include <bits/stdc++.h>
#include "cmp.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) {
    a+=4096;
    owo(i, 0, 6) {
        bit_set(a);
        a/=4;
    }
}
int compare(int b) {
    b+=4096;
    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;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1041 ms 102264 KB ZERO POINTS: For a=3040 and b=3318, correct answer is 1, got -1