/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 504.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Wrong Answer 43ms 860.0 KiB
#4 Wrong Answer 146ms 50.996 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define faster_bro ios_base::sync_with_stdio(false);cin.tie(NULL)
#define esp 0.0000000001
#define ss second
#define ff first
#define nl cout<<endl
//memset(ar,-1,sizeof(ar));
// (1LL<<i) more than efficient pow(2,i);
void fast(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fast();
    int tc;
    cin>>tc;
    int h=1;
    while(tc--){
        ll a,b,c,sum=0,sum1=0,sum2=0,cnt=0,mx=LLONG_MIN,mn=LLONG_MAX,mx1=-1e18,mx2=-1e18;
        cin>>a;
        ll ar[a+1];
        for(int i=1;i<=a;i++){
            cin>>ar[i];
            mx=max(ar[i],mx);
        }
        int bit;
        for(int i=31;i>=0;i--){
               int msk=(1LL) & (mx>>i);
               if(msk==1){
                bit=i;
                break;
               }
        }
        ll dp[a+1][32]={0};
        for(int i=0;i<=bit;i++){
            for(int j=1;j<=a;j++){
                int msk=(1LL) & (ar[j]>>i);

                    dp[j][i]=dp[j-1][i]+msk;
                    //cout<<j<<" "<<i<<" "<<dp[j][i]<<endl;;
            }

        }


        for(int i=1;i<a;i++){
               bool f;
            for(int j=0;j<=bit;j++){
                int l=dp[i][j];

                int l1=dp[a][j]-dp[i][j];
               // cout<<l<<" "<<l1<<endl;
                if((l%2==0 && l1%2==0)||(l%2!=0 && l1%2!=0)){
                   f=true;
                }
                else{
                    f=false;
                    break;
                }
            }
            if(f){
                cnt++;
            }

        }
        cout<<cnt<<endl;
    }
}

Information

Submit By
Type
Submission
Problem
P1096 Mr. Heart and the XOR Puzzle
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-04 13:18:55
Judged At
2024-11-11 02:42:51
Judged By
Score
20
Total Time
146ms
Peak Memory
50.996 MiB