Submission #53029873


Source Code Expand

Copy
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,int> P;
typedef pair<int,P> PP;
bool dp[65][65][65];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,int> P;
typedef pair<int,P> PP; 


bool dp[65][65][65];

int main(){
    ll a,b,C;
    cin>>a>>b>>C;


    ll c=__builtin_popcountll(C);
    
    if(
        (a+b+c)%2!=0 
    || (-a+b+c)<0 
    || (-a+b+c)%2==1 
    || (a+b+c)>120

    || (a-b+c)<0 
    || (a-b+c)%2==1
    
    || (a+b-c)<0
    || (a+b-c)%2==1){
        cout<<-1<<endl;
        return 0;
    }
    
   /*
    if((a + b + c) % 2 != 0 || a + b + c > 120 || a > b + c || b > c + a || c > a + b){
        cout << -1 << endl;
        return 0;
    }
    */
    
    ll n00=60-(a+b+c)/2;
    ll n01=(-a+b+c)/2;
    ll n10=(a-b+c)/2;
    ll n11=(a+b-c)/2;

    vector<vector<pair<int,int>>> S(2);

    for(int t=1;t<=n11;t++){
        S[0].push_back({1,1});
    }
    for(int t=1;t<=n00;t++){
        S[0].push_back({0,0});
    }

    for(int t=1;t<=n01;t++){
        S[1].push_back({0,1});
    }
    for(int t=1;t<=n10;t++){
        S[1].push_back({1,0});
    }

    ll ansX=0,ansY=0;
    //for(int k=60;k>=0;k--){これはNG
    for(unsigned k=60;k--;){//ループ本体がk=0の時にもチェックされる

        //cout<<"k="<<k<<endl;
        ansX*=2;
        ansY*=2;

        int u=(C>>k)&1;

        auto [x,y]=S[u].back();
        ansX+=x;
        ansY+=y;
        S[u].pop_back();

    }
    cout<<ansX<<" "<<ansY<<endl;
    /*
    cout<<__builtin_popcountll(ansX)<<endl;
    cout<<__builtin_popcountll(ansY)<<endl;
    cout<<((ansX^ansY)==C?1:0)<<endl;
    cout<<"te"<<endl;
    */
}

Submission Info

Submission Time
Task D - Popcount and XOR
User HIcoder
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1871 Byte
Status AC
Exec Time 3 ms
Memory 3624 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 47
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 3 ms 3404 KB
00_sample_01.txt AC 1 ms 3412 KB
00_sample_02.txt AC 1 ms 3432 KB
01_random_03.txt AC 1 ms 3368 KB
01_random_04.txt AC 1 ms 3420 KB
01_random_05.txt AC 1 ms 3392 KB
01_random_06.txt AC 1 ms 3364 KB
01_random_07.txt AC 1 ms 3464 KB
01_random_08.txt AC 1 ms 3360 KB
01_random_09.txt AC 1 ms 3416 KB
01_random_10.txt AC 1 ms 3392 KB
01_random_11.txt AC 1 ms 3544 KB
01_random_12.txt AC 1 ms 3464 KB
01_random_13.txt AC 1 ms 3420 KB
01_random_14.txt AC 1 ms 3416 KB
01_random_15.txt AC 1 ms 3552 KB
01_random_16.txt AC 1 ms 3516 KB
01_random_17.txt AC 1 ms 3420 KB
01_random_18.txt AC 1 ms 3464 KB
01_random_19.txt AC 1 ms 3528 KB
01_random_20.txt AC 1 ms 3420 KB
01_random_21.txt AC 1 ms 3452 KB
01_random_22.txt AC 1 ms 3416 KB
01_random_23.txt AC 1 ms 3476 KB
01_random_24.txt AC 1 ms 3456 KB
01_random_25.txt AC 1 ms 3612 KB
01_random_26.txt AC 1 ms 3460 KB
01_random_27.txt AC 1 ms 3520 KB
01_random_28.txt AC 1 ms 3468 KB
01_random_29.txt AC 1 ms 3344 KB
01_random_30.txt AC 1 ms 3532 KB
01_random_31.txt AC 1 ms 3460 KB
01_random_32.txt AC 1 ms 3472 KB
01_random_33.txt AC 1 ms 3400 KB
01_random_34.txt AC 1 ms 3456 KB
01_random_35.txt AC 1 ms 3368 KB
01_random_36.txt AC 1 ms 3476 KB
01_random_37.txt AC 1 ms 3464 KB
01_random_38.txt AC 1 ms 3356 KB
01_random_39.txt AC 1 ms 3424 KB
01_random_40.txt AC 1 ms 3464 KB
01_random_41.txt AC 1 ms 3352 KB
01_random_42.txt AC 1 ms 3396 KB
01_random_43.txt AC 1 ms 3456 KB
01_random_44.txt AC 1 ms 3624 KB
01_random_45.txt AC 1 ms 3432 KB
01_random_46.txt AC 1 ms 3356 KB


2025-04-09 (Wed)
04:35:15 +00:00