Submission #20955024


Source Code Expand

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

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)

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

Submission Info

Submission Time
Task E - Lucky 7 Battle
User ebi_fly
Language C++ (GCC 9.2.1)
Score 500
Code Size 939 Byte
Status AC
Exec Time 49 ms
Memory 21716 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 37
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 6 ms 3408 KiB
hand_02.txt AC 2 ms 3524 KiB
hand_03.txt AC 2 ms 3404 KiB
hand_04.txt AC 2 ms 3480 KiB
random_01.txt AC 48 ms 21560 KiB
random_02.txt AC 41 ms 18932 KiB
random_03.txt AC 47 ms 21568 KiB
random_04.txt AC 39 ms 17868 KiB
random_05.txt AC 46 ms 21636 KiB
random_06.txt AC 31 ms 14208 KiB
random_11.txt AC 49 ms 21716 KiB
random_12.txt AC 36 ms 15592 KiB
random_13.txt AC 48 ms 21568 KiB
random_14.txt AC 35 ms 18188 KiB
random_15.txt AC 44 ms 21624 KiB
random_16.txt AC 38 ms 13520 KiB
random_17.txt AC 46 ms 21716 KiB
random_18.txt AC 35 ms 14280 KiB
random_19.txt AC 49 ms 21712 KiB
random_20.txt AC 35 ms 15232 KiB
random_21.txt AC 47 ms 21620 KiB
random_22.txt AC 43 ms 20300 KiB
random_23.txt AC 48 ms 21620 KiB
random_24.txt AC 42 ms 17676 KiB
random_25.txt AC 47 ms 21564 KiB
random_26.txt AC 35 ms 13112 KiB
random_31.txt AC 30 ms 21560 KiB
random_32.txt AC 28 ms 21632 KiB
random_33.txt AC 30 ms 21664 KiB
random_41.txt AC 43 ms 21596 KiB
random_42.txt AC 43 ms 21664 KiB
random_43.txt AC 31 ms 21564 KiB
random_44.txt AC 25 ms 21636 KiB
sample_01.txt AC 2 ms 3472 KiB
sample_02.txt AC 2 ms 3420 KiB
sample_03.txt AC 2 ms 3604 KiB
sample_04.txt AC 2 ms 3480 KiB