QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207916#6641. XOR DiceUFRJ#WA 31ms8280kbC++14922b2023-10-08 22:59:012023-10-08 22:59:02

Judging History

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

  • [2023-10-08 22:59:02]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:8280kb
  • [2023-10-08 22:59:01]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int LIM = 1000000;

void solve(int d, int N){
    vector<int> v; v.reserve(LIM + 1);
    for(int cur = 1; cur*d <= LIM; cur ++)
        v.push_back(cur * d);
    auto v2 = v;
    sort(v2.begin(), v2.end());
    sort(v.begin(), v.end(), [](int a, int b){
        return __builtin_popcount(a) < __builtin_popcount(b); 
    });
    vector<int> ans;
    int accum = 0;
    for(int x : v){
        if((x | accum) == (x ^ accum)){
            ans.push_back(x);
            accum += x;
        }
        if(ans.size() == 5) break;
    }
    if(ans.size() == 4){
        ans.push_back(ans[0] + ans[1]);
    }
    assert(ans.size() == 5);
    while(N--){
        for(int x : ans) cout<<x<<" ";
        cout<<"\n";
    }
}


int main(){
    cin.tie(0)->sync_with_stdio(false);
    int n, d;
    cin>>n>>d;
    solve(d, n);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 31ms
memory: 8280kb

input:

3 2

output:

512 1024 262144 65536 4096 
512 1024 262144 65536 4096 
512 1024 262144 65536 4096 

result:

wrong answer Invalid output