Submission #51871701


Source Code Expand

import sys
import math
# Fast input
input = sys.stdin.readline
# Fast output
def print(*args, **kwargs):
    sep = kwargs.get('sep', ' ')
    end = kwargs.get('end', '\n')
    file = kwargs.get('file', sys.stdout)
    flush = kwargs.get('flush', False)
    output = sep.join(map(str, args)) + end
    file.write(output)
    if flush:
        file.flush()



from types import GeneratorType
def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to
    return wrappedfunc
# @bootstrap
# def dfs(node, parent, x):
#     sx = 1
#     for i in graph[node]:
#         if i==parent:
#             continue
#         sx += yield dfs(i, node, x)
#     if sx >= x:
#         ans[0] += 1
#         sx = 0
#     yield sx


        
from collections import Counter, deque, defaultdict
from itertools import accumulate, product, groupby, combinations
import operator
import math
import bisect
import heapq

def readIntLine():
    return [int(char) for char in input().split()]

def readCharLine():
    return [char for char in input().split()]

def modmul(a, b, mod):
    a %= mod
    b %= mod
    return (a * b) % mod

def modadd(a, b, mod):
    a %= mod
    b %= mod
    return (a+b)%mod
    
def modsub(a, b, mod):
    a %= mod
    b %= mod
    return (a - b + mod)%mod



def modInverse(A, M):
    for X in range(1, M):
        if (((A % M) * (X % M)) % M == 1):
            return X
    return -1


def gcd(a,b):
    if b== 0:
        return a
    return gcd(b, a%b)

def is_coprime(a,b):
    return gcd(a,b)==1

def expo(a, n, mod):
    res = 1
    while n:
        if n&1:
            res = modmul(res,a,mod)
            n -= 1
        else:
            a = modmul(a,a,mod)
            n >>= 1
    return res

def get_mex(arr, N):
    arr = sorted(arr)
    mex = 0
    for idx in range(N):
        if arr[idx] == mex:
            mex += 1
    return mex

def solve():
    # n = int(input())
    a, b, C = map(int,input().split())
    # s = input().rstrip('\n')
    # A = readIntLine()
    # B = readIntLine()
    # MOD = 1000000007

    a_one, b_one = a, b
    A, B = [], []
    indices = []
    for i in range(63):
        x = (1<<i)
        if x&C:
            if a_one>b_one:
                A.append(1)
                B.append(0)
                a_one -= 1
            else:
                A.append(0)
                B.append(1)
                b_one -= 1
        else:
            A.append(0)
            B.append(0)
            indices.append(i)
    
    # these are indices where C is zero
    for i in indices:
        if a_one and b_one:
            A[i] = 1
            B[i] = 1
            a_one -= 1
            b_one -= 1
    
    if a_one and not b_one:
        print(-1)
        return
    if b_one and not a_one:
        print(-1)
        return
    
    # A.reverse()
    # B.reverse()
    # print(A)
    # print(B)
        
    ans_a = 0
    ans_b = 0
    for i in range(63):
        if A[i]:
            ans_a += (1<<i)
        if B[i]:
            ans_b += (1<<i)
    
    if ans_a ^ ans_b == C:
        print(ans_a, ans_b)
    else:
        print(-1)



    # n, a, b = map(int,input().split())
    # A = readIntLine()
    # t = a+b
    # arr = [x%t for x in A]

    # mn, mx = min(arr), max(arr)

    # if mx-mn < a:
    #     print("Yes")
    # else:
    #     print("No")

    # intervals = []
    # for x in arr:
    #     l = 1-x
    #     r = a-x

    #     l = (l+t)%t
    #     r = (r+t)%t

    #     intervals.append([l,r])
    
    # print(intervals)
    # intervals.sort()

    # stack = []
    # for start, end in intervals:
    #     if not stack:
    #         stack.append([start, end])
    #         continue
        
    #     prev_start, prev_end = stack[-1]
    #     if start > prev_end:
    #         print("No")
    #         return
        
    #     stack[-1][0] = max(stack[-1][0], start)
    
    # print("Yes")

solve()   
# for i in range(int(input())):
#     solve()

Submission Info

Submission Time
Task D - Popcount and XOR
User kaicoder0
Language Python (CPython 3.11.4)
Score 0
Code Size 4571 Byte
Status WA
Exec Time 12 ms
Memory 9816 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 45
WA × 2
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 12 ms 9720 KiB
00_sample_01.txt AC 12 ms 9716 KiB
00_sample_02.txt AC 12 ms 9632 KiB
01_random_03.txt AC 12 ms 9700 KiB
01_random_04.txt AC 12 ms 9816 KiB
01_random_05.txt AC 12 ms 9760 KiB
01_random_06.txt AC 12 ms 9676 KiB
01_random_07.txt AC 12 ms 9604 KiB
01_random_08.txt AC 12 ms 9708 KiB
01_random_09.txt AC 12 ms 9732 KiB
01_random_10.txt AC 12 ms 9612 KiB
01_random_11.txt AC 12 ms 9660 KiB
01_random_12.txt AC 12 ms 9716 KiB
01_random_13.txt AC 12 ms 9724 KiB
01_random_14.txt AC 12 ms 9692 KiB
01_random_15.txt AC 12 ms 9668 KiB
01_random_16.txt AC 12 ms 9628 KiB
01_random_17.txt AC 12 ms 9716 KiB
01_random_18.txt AC 12 ms 9692 KiB
01_random_19.txt AC 12 ms 9636 KiB
01_random_20.txt AC 12 ms 9708 KiB
01_random_21.txt AC 12 ms 9780 KiB
01_random_22.txt AC 12 ms 9748 KiB
01_random_23.txt AC 12 ms 9672 KiB
01_random_24.txt AC 12 ms 9684 KiB
01_random_25.txt AC 12 ms 9768 KiB
01_random_26.txt AC 12 ms 9744 KiB
01_random_27.txt AC 12 ms 9728 KiB
01_random_28.txt AC 12 ms 9660 KiB
01_random_29.txt AC 12 ms 9600 KiB
01_random_30.txt AC 12 ms 9700 KiB
01_random_31.txt AC 12 ms 9644 KiB
01_random_32.txt AC 12 ms 9616 KiB
01_random_33.txt AC 12 ms 9616 KiB
01_random_34.txt AC 12 ms 9604 KiB
01_random_35.txt AC 12 ms 9704 KiB
01_random_36.txt AC 12 ms 9640 KiB
01_random_37.txt AC 12 ms 9668 KiB
01_random_38.txt AC 12 ms 9756 KiB
01_random_39.txt AC 12 ms 9688 KiB
01_random_40.txt WA 12 ms 9724 KiB
01_random_41.txt AC 12 ms 9724 KiB
01_random_42.txt AC 12 ms 9736 KiB
01_random_43.txt AC 12 ms 9684 KiB
01_random_44.txt AC 12 ms 9604 KiB
01_random_45.txt AC 12 ms 9744 KiB
01_random_46.txt WA 12 ms 9716 KiB