結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー hitonanode
提出日時 2023-06-17 13:49:39
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 955 ms
コンパイル使用メモリ 83,836 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 04:43:05
合計ジャッジ時間 7,276 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

#include <atcoder/modint>
using mint = atcoder::modint;

mint w[4];

int main() {
    int N;
    cin >> N;
    long long suma = 0;
    int cnt3 = 0;

    mint ret = 1;

    for (int i = 0; i < N; ++i) {
        char c;
        int a;
        cin >> c >> a;
        suma += a;
        int d = (c == 'U' ? 0 : (c == 'F' ? 1 : (c == 'W' ? 2 : 3)));
        cnt3 += (d == 3);
        w[d] += 1 - (mint(N - 2) / (N - 1)).pow(a);
        ret *= mint(N - 1).pow(a);
    }
    cout << (w[0] * w[1] * w[2] * ret * cnt3).val() << endl;
}
0