Submission #46004976


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/modint>

void solve(std::istream& is, std::ostream& os) {
    using Num = long long int;
    using ModInt = atcoder::modint998244353;
    Num n {0};
    Num k {0};
    is >> n >> k;

    std::vector<Num> fixed(n+1, 0);
    std::vector<Num> ns(n+1, 0);
    for(Num i{1}; i<=k; ++i) {
        char c {0};
        Num a {0};
        is >> c >> a;

        fixed.at(a) = i;
        if (c == 'L') {
            for(Num j{a}; j<=n; ++j) {
                ns.at(j) += 1;
            }
        } else {
            for(Num j{1}; j<=a; ++j) {
                ns.at(j) += 1;
            }
        }
    }

    ModInt combi {1};
    for(Num i{1}; i<=n; ++i) {
        if (fixed.at(i) == 0) {
            combi *= ns.at(i);
        }
    }

    os << combi.val() << "\n";
    return;
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

Submission Info

Submission Time
Task A - LR Constraints
User zettsut
Language C++ 20 (gcc 12.2)
Score 300
Code Size 927 Byte
Status AC
Exec Time 1 ms
Memory 3620 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All 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
Case Name Status Exec Time Memory
random_01.txt AC 1 ms 3620 KiB
random_02.txt AC 1 ms 3444 KiB
random_03.txt AC 1 ms 3464 KiB
random_04.txt AC 1 ms 3460 KiB
random_05.txt AC 1 ms 3492 KiB
random_06.txt AC 1 ms 3488 KiB
random_07.txt AC 1 ms 3440 KiB
random_08.txt AC 1 ms 3616 KiB
random_09.txt AC 1 ms 3584 KiB
random_10.txt AC 1 ms 3436 KiB
random_11.txt AC 1 ms 3456 KiB
random_12.txt AC 1 ms 3408 KiB
random_13.txt AC 1 ms 3472 KiB
random_14.txt AC 1 ms 3496 KiB
random_15.txt AC 1 ms 3456 KiB
sample_01.txt AC 1 ms 3540 KiB
sample_02.txt AC 1 ms 3612 KiB