結果

問題 No.762 PDCAパス
ユーザー cielciel
提出日時 2018-12-11 00:48:09
言語 Crystal
(1.11.2)
結果
WA  
実行時間 -
コード長 403 bytes
コンパイル時間 17,639 ms
コンパイル使用メモリ 256,200 KB
実行使用メモリ 8,432 KB
最終ジャッジ日時 2023-09-13 09:56:03
合計ジャッジ時間 19,800 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 3 ms
4,464 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 3 ms
4,456 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
4,428 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,412 KB
testcase_20 WA -
testcase_21 AC 3 ms
4,404 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 36 ms
8,192 KB
testcase_29 AC 37 ms
8,432 KB
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 #

n,m=gets.not_nil!.split.map &.to_i
s=gets.not_nil!.chomp
a=n.times.map{Tuple(Int32,Int32).from(gets.not_nil!.split.map{|f|f.to_i-1})}.to_a
d=[0]*n
r=0
a.each{|x,y|
	d[y]+=1 if s[x]=='P'&&s[y]=='D'
	d[x]+=1 if s[y]=='P'&&s[x]=='D'
}
a.each{|x,y|
	d[y]+=d[x] if s[x]=='D'&&s[y]=='C'
	d[x]+=d[y] if s[y]=='D'&&s[x]=='C'
}
a.each{|x,y|
	r+=d[x] if s[x]=='C'&&s[y]=='A'
	r+=d[y] if s[y]=='C'&&s[x]=='A'
}
p r
0