提出 #50169550


ソースコード 拡げる

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

namespace {
    using ModInt [[maybe_unused]] = atcoder::modint998244353;
    using Num [[maybe_unused]] = long long int;
    using Vec [[maybe_unused]] = std::vector<Num>;
    using Set [[maybe_unused]] = std::set<Num>;
    using Mset [[maybe_unused]] = std::multiset<Num>;
    using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

    template<typename T>
    using Q [[maybe_unused]] = std::queue<T>;

    template<typename T>
    using PQ [[maybe_unused]] = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}

Num func_operate(Num a, Num b) {
    return a + b;
}

Num func_unit() {
    return 0;
}

Num func_map(Num a, Num b) {
    return a + b;
}

Num func_compose(Num a, Num b) {
    return a + b;
}

Num func_id() {
    return 0;
}

void solve(std::istream& is, std::ostream& os) {
    Num n, m;
    is >> n >> m;

    atcoder::lazy_segtree<Num, func_operate, func_unit, Num, func_map, func_compose, func_id> tree(n);
    for(Num i{0}; i<n; ++i) {
        Num a;
        is >> a;
        tree.set(i, a);
    }

    Vec bset(m);
    for(auto&& b : bset) {
        is >> b;
    }

    for(Num i{0}; i<m; ++i) {
        const auto box = bset.at(i);
        auto ct = tree.get(box);
        tree.set(box, 0);
        if (ct == 0) {
            continue;
        }

        Num div = ct / n;
        Num rem = ct % n;
        tree.apply(0, n, div);

        Num left = box + 1;
        Num right = left + rem;
        if (right <= n) {
            tree.apply(left, right, 1);
        } else {
            tree.apply(left, n, 1);
            right %= n;
            tree.apply(0, right, 1);
        }
    }

    for(Num i{0}; i<n; ++i) {
        os << tree.get(i);
        if ((i+1) == n) {
            os << "\n";
        } else {
            os << " ";
        }
    }
}

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

提出情報

提出日時
問題 E - Mancala 2
ユーザ zettsut
言語 C++ 20 (gcc 12.2)
得点 475
コード長 2032 Byte
結果 AC
実行時間 230 ms
メモリ 10972 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 475 / 475
結果
AC × 3
AC × 35
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.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, 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_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 44 ms 4752 KiB
random_02.txt AC 74 ms 4672 KiB
random_03.txt AC 43 ms 4144 KiB
random_04.txt AC 2 ms 3676 KiB
random_05.txt AC 65 ms 4756 KiB
random_06.txt AC 73 ms 4648 KiB
random_07.txt AC 30 ms 4200 KiB
random_08.txt AC 24 ms 3704 KiB
random_09.txt AC 74 ms 4720 KiB
random_10.txt AC 67 ms 4752 KiB
random_11.txt AC 37 ms 4204 KiB
random_12.txt AC 8 ms 3540 KiB
random_13.txt AC 230 ms 10752 KiB
random_14.txt AC 170 ms 7652 KiB
random_15.txt AC 145 ms 10880 KiB
random_16.txt AC 88 ms 4976 KiB
random_17.txt AC 228 ms 10792 KiB
random_18.txt AC 208 ms 10820 KiB
random_19.txt AC 160 ms 10828 KiB
random_20.txt AC 180 ms 7704 KiB
random_21.txt AC 226 ms 10736 KiB
random_22.txt AC 211 ms 10696 KiB
random_23.txt AC 171 ms 10776 KiB
random_24.txt AC 180 ms 10784 KiB
random_25.txt AC 1 ms 3404 KiB
random_26.txt AC 1 ms 3684 KiB
random_27.txt AC 221 ms 10972 KiB
random_28.txt AC 122 ms 5456 KiB
random_29.txt AC 171 ms 7756 KiB
random_30.txt AC 79 ms 4732 KiB
random_31.txt AC 80 ms 4728 KiB
random_32.txt AC 77 ms 4708 KiB
sample_01.txt AC 1 ms 3536 KiB
sample_02.txt AC 1 ms 3408 KiB
sample_03.txt AC 1 ms 3552 KiB