結果

問題 No.762 PDCAパス
ユーザー iicafiaxusiicafiaxus
提出日時 2018-12-10 12:39:01
言語 D
(dmd 2.107.1)
結果
TLE  
実行時間 -
コード長 1,321 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 116,028 KB
実行使用メモリ 23,328 KB
最終ジャッジ日時 2023-09-03 21:31:04
合計ジャッジ時間 7,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 929 ms
12,132 KB
testcase_23 AC 932 ms
13,388 KB
testcase_24 AC 124 ms
21,976 KB
testcase_25 AC 124 ms
23,328 KB
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

const long MOD = 1000000007;

class Node{
 int id;
 char value;
 Node[] nodes;
 this(int id){
  this.id = id;
 }
 override string toString(){
  return this.id.to!string ~ " " ~ this.value;
 }
}


void main(){
 int n = read.to!int;
 Node[] nodes;
 foreach(i; 0 .. n) nodes ~= new Node(i);

 int m = read.to!int;
	
 string s = readln.chomp;
 foreach(i, c; s) nodes[i].value = c;
	
 foreach(i; 0 .. m){
  int u = read.to!int - 1, v = read.to!int - 1;
  nodes[u].nodes ~= nodes[v];
  nodes[v].nodes ~= nodes[u];
 }
	
 long temp1 = 0;
 foreach(nd1; nodes){
  if(nd1.value != 'P') continue;
  long temp2 = 0;
  foreach(nd2; nd1.nodes){
   if(nd2.value != 'D') continue;
   long temp3 = 0;
   foreach(nd3; nd2.nodes){
    if(nd3.value != 'C') continue;
    long temp4 = 0;
    foreach(nd4; nd3.nodes){
     if(nd4.value != 'A') continue;
     temp4 += 1;
     temp4 %= MOD;
    }
    temp3 += temp4;
    temp3 %= MOD;
   }
   temp2 += temp3;
   temp2 %= MOD;
  }
  temp1 += temp2;
  temp1 %= MOD;
 }
	
 auto ans = temp1;
 ans.writeln;
}
0