提出 #20955099


ソースコード 拡げる

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)

int main() {
    int n;
    std::string s,x;
    std::cin >> n >> s >> x;
    std::vector dp(n+1, std::vector<int>(7,0));
    dp[n][0] = 1;
    int ten = 1;
    rrep(i,0,n) {
        int c = (s[i]-'0')*ten%7;
        rep(j,0,7) {
            if(x[i] == 'T') {
                dp[i][j] = std::max(dp[i+1][j], dp[i+1][(j+c)%7]);
            }
            else {
                dp[i][j] = std::min(dp[i+1][j], dp[i+1][(j+c)%7]);
            }
        }
        ten *= 10;
        ten %= 7;
    }
    std::cout << ((dp[0][0] == 1) ? "Takahashi" : "Aoki") << std::endl;
}

提出情報

提出日時
問題 E - Lucky 7 Battle
ユーザ ebi_fly
言語 C++ (GCC 9.2.1)
得点 500
コード長 807 Byte
結果 AC
実行時間 28 ms
メモリ 10632 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 4
AC × 37
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_31.txt, random_32.txt, random_33.txt, random_41.txt, random_42.txt, random_43.txt, random_44.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 8 ms 3476 KiB
hand_02.txt AC 2 ms 3476 KiB
hand_03.txt AC 2 ms 3408 KiB
hand_04.txt AC 2 ms 3616 KiB
random_01.txt AC 24 ms 10204 KiB
random_02.txt AC 20 ms 9256 KiB
random_03.txt AC 24 ms 10224 KiB
random_04.txt AC 21 ms 8996 KiB
random_05.txt AC 19 ms 10280 KiB
random_06.txt AC 16 ms 7384 KiB
random_11.txt AC 28 ms 10252 KiB
random_12.txt AC 16 ms 7784 KiB
random_13.txt AC 24 ms 10272 KiB
random_14.txt AC 17 ms 8880 KiB
random_15.txt AC 23 ms 10292 KiB
random_16.txt AC 16 ms 7148 KiB
random_17.txt AC 25 ms 10248 KiB
random_18.txt AC 16 ms 7464 KiB
random_19.txt AC 28 ms 10292 KiB
random_20.txt AC 16 ms 7992 KiB
random_21.txt AC 28 ms 10224 KiB
random_22.txt AC 19 ms 9784 KiB
random_23.txt AC 24 ms 10220 KiB
random_24.txt AC 21 ms 8944 KiB
random_25.txt AC 21 ms 10312 KiB
random_26.txt AC 14 ms 6992 KiB
random_31.txt AC 25 ms 10268 KiB
random_32.txt AC 25 ms 10264 KiB
random_33.txt AC 26 ms 10272 KiB
random_41.txt AC 22 ms 10220 KiB
random_42.txt AC 24 ms 10224 KiB
random_43.txt AC 22 ms 10632 KiB
random_44.txt AC 20 ms 10220 KiB
sample_01.txt AC 3 ms 3404 KiB
sample_02.txt AC 2 ms 3540 KiB
sample_03.txt AC 2 ms 3456 KiB
sample_04.txt AC 2 ms 3624 KiB