結果

問題 No.3550 Another Rurumaru Function Problem
コンテスト
ユーザー LyricalMaestro
提出日時 2026-05-24 03:18:56
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 1,551 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 615 ms
コンパイル使用メモリ 85,516 KB
実行使用メモリ 235,300 KB
最終ジャッジ日時 2026-05-24 03:19:07
合計ジャッジ時間 9,820 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# https://yukicoder.me/problems/no/3550



def main():
    N = int(input())
    A = list(map(int, input().split()))

    a_list = []
    for a in A:
        array = []
        for k in range(30):
            array.append(a % 2)
            a //= 2
        a_list.append(array)
    
    answer = [0] * 30
    for k in reversed(range(30)):
        if k % 2 == 1:
            is_ok = False
            for i in range(len(a_list)):
                if a_list[i][k] == 1:
                    is_ok = True

            if is_ok:
                answer[k] = 1
            else:
                answer[k] = 0
        else:
            is_ok = True
            array = []
            for i in range(len(a_list)):
                if a_list[i][k] == 1:
                    array.append(i)

            if len(array) > 0:
                for l in range(k + 1, 30, 2):
                    if answer[l] == 1:
                        is_ok2 = False
                        for i in array:
                            if a_list[i][l] == 1:
                                is_ok2 = True
                        if not is_ok2:
                            is_ok = False
            else:
                is_ok = False
            
            if is_ok:
                answer[k] = 1
                a_list = [a_list[i] for i in array]
            else:
                answer[k] = 0

    ans = 0
    for k in range(30):
        ans += answer[k] * (2 ** k)
    print(ans)                                



        

        









if __name__ == "__main__":
    main()
0