QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189986#4425. Cakeberarchegas#WA 124ms3864kbC++201.7kb2023-09-28 04:07:252023-09-28 04:07:25

Judging History

你现在查看的是最新测评结果

  • [2023-09-28 04:07:25]
  • 评测
  • 测评结果:WA
  • 用时:124ms
  • 内存:3864kb
  • [2023-09-28 04:07:25]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)

using namespace std;

int solve(vector<int> v, int k, int bit) {
    if (bit == -1) return v.size();
    vector<int> v0, v1;
    for (int x : v) {
        if (x & (1 << bit)) v1.push_back(x);
        else v0.push_back(x);
    }
    if (k & (1 << bit)) {
        return max({(int)v0.size(), (int)v1.size(), solve(v, k, bit - 1)});
    }   
    else {
        return max(solve(v0, k, bit - 1), solve(v1, k, bit - 1));
    }
}


int bruteSolve(vector<int> v,int k){
    int n = v.size();
    int res=0;
    for(int msk=0;msk<(1<<n);msk++){
        int ok = 1;
        vector<int> here;
        rep(i,0,n)if(msk>>i&1){
            here.push_back(v[i]);
        }
        for(auto x : here)for(auto y : here){
            if((x^y) > k){
                ok = 0;
                break;
            }
        }
        if(ok)res = max(res,(int)here.size());
    }
    return res;
}


mt19937 rng(123);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    // cin >> t;
    t = 100;
    for(int tt =1 ; tt<=t; tt++){
        if(tt % 5==0){
            cout << tt << endl;
        }
        int n, k;
        // cin >> n >> k;
        n = rng()%4 + 1, k = rng()%8+1;
        vector<int> v(n);
        for (int &x : v) {
            // cin >> x;
            x = rng()%8;    
        }
        // cout << solve(v, k, 19) << '\n';
        if(solve(v,k,19) != bruteSolve(v, k)){
            cout << n<<" " << k << endl;
            for(auto x : v)cout << x<<" ";
            cout << endl;
            cout << bruteSolve(v,k) << " " << solve(v,k,19) << endl;
            break;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 124ms
memory: 3864kb

input:

4
500000
471518156 319758862 812815356 520822448 129241996 461169933 796713727 608641317 281180101 953966756 749634941 274104949 996181952 88142916 998544672 125597509 991731126 974767231 338911715 674197249 167602044 682799026 226927279 703198907 216742488 8185420 94921423 690039818 859329736 45428...

output:

5
10
15
20
25
4 6
1 7 1 2 
4 3

result:

wrong answer 1st lines differ - expected: '0', found: '5'