結果

問題 No.762 PDCAパス
ユーザー htensaihtensai
提出日時 2019-12-30 09:38:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,638 bytes
コンパイル時間 2,777 ms
コンパイル使用メモリ 78,304 KB
実行使用メモリ 55,728 KB
最終ジャッジ日時 2024-04-25 08:16:23
合計ジャッジ時間 24,445 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,216 KB
testcase_01 AC 133 ms
41,296 KB
testcase_02 AC 137 ms
41,104 KB
testcase_03 AC 135 ms
41,148 KB
testcase_04 AC 136 ms
41,412 KB
testcase_05 AC 123 ms
40,016 KB
testcase_06 WA -
testcase_07 AC 121 ms
40,200 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 133 ms
41,240 KB
testcase_14 AC 133 ms
40,820 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 141 ms
41,368 KB
testcase_18 WA -
testcase_19 AC 138 ms
41,336 KB
testcase_20 WA -
testcase_21 AC 143 ms
41,292 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        long[] counts = new long[n];
        ArrayList<Integer>[] lists = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            if (arr[i] == 'D') {
                lists[i] = new ArrayList<Integer>();
            }
        }
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            if (arr[a] == 'P') {
                if (arr[b] == 'D') {
                    counts[b]++;
                }
            } else if (arr[a] == 'D') {
                if (arr[b] == 'P') {
                    counts[a]++;
                } else if (arr[b] == 'C') {
                    lists[a].add(b);
                }
            } else if (arr[a] == 'C') {
                if (arr[b] == 'D') {
                    lists[b].add(a);
                } else if (arr[b] == 'A') {
                    counts[b]++;
                }
            } else if (arr[a] == 'A') {
                if (arr[b] == 'C') {
                    counts[b]++;
                }
            }
        }
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] != 'D') {
                continue;
            }
            for (int x : lists[i]) {
                total += counts[i] * counts[x];
                total %= MOD;
            }
        }
        System.out.println(total);
    }
}
0