QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#954343#10010. Kids And Sequence GameAfterlife#WA 10ms3968kbC++201011b2025-03-28 17:41:462025-03-28 17:41:47

Judging History

This is the latest submission verdict.

  • [2025-03-28 17:41:47]
  • Judged
  • Verdict: WA
  • Time: 10ms
  • Memory: 3968kb
  • [2025-03-28 17:41:46]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=500050;
int n,op;
ll a[N];
int A;
vector<int> B;
void Ins(ll x){
    vector<int> st;
    while(x){
        int c=x&1;
        x>>=1;
        if(!st.empty()&&st.back()==c){
            st.pop_back();
            continue;
        }
        st.push_back(c);
    }
    if(st.empty())return;
    int t=0;
    for(auto z:st)t+=z;
    if(st[0]==1){
        op^=1;
        --t;
    }
    if(st.back()==1)A+=t;
    else B.push_back(t);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        Ins(a[i]);
    }
    ll ans=0;
    sort(B.begin(),B.end());
    if(op==1)ans++;
    for(auto x:B){
        if(op==0){
            ans-=x;
        }
        else{
            ans+=x;
        }
        op^=1;
    }
    if(op==0){
        ans-=A;
    }
    else{
        ans+=A;
    }
    cout<<ans<<'\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

5
13 29 10 1 26

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 3968kb

input:

21417
7840302172680170307 5321573529083198387 8214462622877325148 1143008495081213578 6262491513147717806 5039611704168873788 8094944116872031972 2567428672066144766 6056648091050202450 3565740003036766392 2925999037919145749 5542147304038247878 862707825558040953 4471890990246559484 263325942648568...

output:

35556

result:

wrong answer 1st numbers differ - expected: '67086', found: '35556'