提出 #19618485


ソースコード 拡げる

import sys
input = sys.stdin.readline
import numpy as np

#    int(input())
#    input().split().strip()
#    map(int, input().strip().split())

n = int(input())

def input_str2bool():
    s = input()
    if s[0] == "T":
        return True
    else:
        return False

TF = [input().strip() for _ in range(n)]
def saikick(TF):
    if len(TF) == 1:
        if TF[0] == "AND":
            return 1
        else:
            return 3
    if TF[-1] == "OR":
        return 2**(len(TF)) + saikick(TF[:-1])
    else:
        return saikick(TF[:-1])

ans = saikick(TF)
print(ans)

提出情報

提出日時
問題 D - Logical Expression
ユーザ rsypoz
言語 Python (3.8.2)
得点 400
コード長 608 Byte
結果 AC
実行時間 113 ms
メモリ 27064 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 21
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All max_01.txt, max_02.txt, min_01.txt, min_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
max_01.txt AC 113 ms 26928 KiB
max_02.txt AC 109 ms 26984 KiB
min_01.txt AC 106 ms 27048 KiB
min_02.txt AC 105 ms 26864 KiB
random_01.txt AC 108 ms 26768 KiB
random_02.txt AC 105 ms 26644 KiB
random_03.txt AC 109 ms 26940 KiB
random_04.txt AC 109 ms 26568 KiB
random_05.txt AC 107 ms 26668 KiB
random_06.txt AC 107 ms 26904 KiB
random_07.txt AC 106 ms 26568 KiB
random_08.txt AC 105 ms 26792 KiB
random_09.txt AC 106 ms 26804 KiB
random_10.txt AC 106 ms 26924 KiB
random_11.txt AC 108 ms 26932 KiB
random_12.txt AC 106 ms 26564 KiB
random_13.txt AC 108 ms 26940 KiB
random_14.txt AC 105 ms 27064 KiB
random_15.txt AC 105 ms 27008 KiB
sample_01.txt AC 106 ms 26868 KiB
sample_02.txt AC 108 ms 26888 KiB