結果

問題 No.762 PDCAパス
ユーザー るさるさ
提出日時 2019-04-09 21:45:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,338 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 49,428 KB
最終ジャッジ日時 2023-09-18 11:41:29
合計ジャッジ時間 20,173 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,044 KB
testcase_01 AC 16 ms
8,044 KB
testcase_02 AC 17 ms
8,000 KB
testcase_03 AC 16 ms
8,172 KB
testcase_04 AC 16 ms
8,116 KB
testcase_05 AC 17 ms
8,116 KB
testcase_06 AC 16 ms
8,160 KB
testcase_07 AC 16 ms
8,060 KB
testcase_08 AC 16 ms
8,044 KB
testcase_09 AC 17 ms
8,004 KB
testcase_10 AC 16 ms
8,108 KB
testcase_11 AC 17 ms
8,048 KB
testcase_12 AC 17 ms
8,152 KB
testcase_13 AC 16 ms
8,160 KB
testcase_14 AC 17 ms
8,184 KB
testcase_15 AC 16 ms
8,052 KB
testcase_16 AC 17 ms
8,048 KB
testcase_17 AC 17 ms
8,156 KB
testcase_18 AC 17 ms
8,104 KB
testcase_19 AC 17 ms
8,148 KB
testcase_20 AC 17 ms
8,072 KB
testcase_21 AC 16 ms
8,044 KB
testcase_22 AC 563 ms
26,884 KB
testcase_23 AC 557 ms
26,864 KB
testcase_24 AC 706 ms
49,428 KB
testcase_25 AC 705 ms
49,268 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1,234 ms
47,956 KB
testcase_29 AC 1,231 ms
47,864 KB
testcase_30 AC 1,170 ms
44,228 KB
testcase_31 AC 1,157 ms
44,100 KB
testcase_32 AC 1,155 ms
44,092 KB
testcase_33 AC 1,143 ms
39,384 KB
testcase_34 AC 1,145 ms
39,528 KB
testcase_35 AC 1,140 ms
39,580 KB
testcase_36 AC 926 ms
30,616 KB
testcase_37 AC 932 ms
30,720 KB
testcase_38 AC 974 ms
30,600 KB
testcase_39 AC 953 ms
30,688 KB
testcase_40 AC 964 ms
30,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
class Node:
	def __init__(self):
		self.edge=[]
		self.degree=0
		self.word=""
		self.cnt=0
	
	def add_edge(self,new_edge):
		self.edge.append(new_edge)
		self.degree+=1


class Edge:
	def __init__(self,node_a,node_b):
		node_a.add_edge(self)
		node_b.add_edge(self)
		self.node=(node_a,node_b)


class Graph:
	def __init__(self):
		self.node={}
		self.edge=[]
	
	def add_edge(self,new_edge):
		if not new_edge[0] in self.node:
			self.node[new_edge[0]]=Node()
		if not new_edge[1] in self.node:
			self.node[new_edge[1]]=Node()
		self.edge.append(Edge(self.node[new_edge[0]],self.node[new_edge[1]]))

n,m=map(int,input().split())
s=input()
g=Graph()
for i in range(m):
    g.add_edge(list(map(int,input().split())))
for i in range(len(s)):
    if i+1 in g.node:
        g.node[i+1].word=s[i]

for i in g.edge:
    a,b=i.node[0],i.node[1]
    if (a.word=="P") and (b.word=="D"):
        b.cnt+=1
    if (a.word=="D") and (b.word=="P"):
        a.cnt+=1
        
for i in g.edge:
    a,b=i.node[0],i.node[1]
    if (a.word=="D") and (b.word=="C"):
        b.cnt+=a.cnt
    if (a.word=="C") and (b.word=="D"):
        a.cnt+=b.cnt
c=0

for i in g.edge:
    a,b=i.node[0],i.node[1]
    if (a.word=="C") and (b.word=="A"):
        c+=a.cnt
    if (a.word=="A") and (b.word=="C"):
        c+=b.cnt
print(c)


0