結果

問題 No.1372 Median of Submasks
ユーザー OmameBeansOmameBeans
提出日時 2021-02-05 23:19:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,770 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 174,140 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-15 10:49:48
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 8 ms
4,384 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 8 ms
4,384 KB
testcase_13 AC 8 ms
4,380 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

string d(ll n) {
    string ans = "";
    REP(i,60) {
        ans += n%2 + '0';
        n /= 2;
    }
    return ans;
}

ll f(string S) {
    ll ans = 0;
    ll q = 1;
    REP(i,S.size()) {
        if(S[i] == '1') ans += q;
        q *= 2;
    }
    return ans;
}

ll pow(int a, int n) {
    ll ans = 1;
    REP(i,n) ans *= a;
    return ans;
}

int main() {
    ll N; cin >> N;
    if(N == 1) {
        cout << 1 << endl;
        return 0;
    }

    string S = d(N);
    //cout << S << endl;
    vector<string> T(4);
    ll ans = 0;

    T[0] = S.substr(0,15);
    T[1] = S.substr(15,30);
    T[2] = S.substr(30,45);
    T[3] = S.substr(45,60);

    REP(i,4) {
        vecl res;
        ll s;
        if(i == 0) s = 1;
        else s = 0;
        for(ll x = s; x < (1LL<<15); x++) {
            //if(x <= f(T[i])) cout << (x & f(T[i])) << endl;
            if((x & f(T[i])) == x) {
                res.push_back(x);
            }
        }
        sort(res.begin(),res.end());
        if(res.size() > 0) ans += res[res.size()/2] * pow(2LL,15LL*i);
    }
    
    cout << ans << endl;
    return 0;
}
0