結果

問題 No.762 PDCAパス
ユーザー るさるさ
提出日時 2019-04-09 21:39:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,312 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 49,308 KB
最終ジャッジ日時 2023-09-18 11:12:00
合計ジャッジ時間 20,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,032 KB
testcase_01 AC 17 ms
8,008 KB
testcase_02 AC 17 ms
8,120 KB
testcase_03 AC 17 ms
8,172 KB
testcase_04 AC 17 ms
8,116 KB
testcase_05 RE -
testcase_06 AC 16 ms
8,060 KB
testcase_07 AC 17 ms
8,124 KB
testcase_08 AC 18 ms
8,096 KB
testcase_09 AC 17 ms
8,000 KB
testcase_10 AC 17 ms
8,000 KB
testcase_11 AC 18 ms
8,116 KB
testcase_12 AC 17 ms
8,032 KB
testcase_13 AC 17 ms
8,008 KB
testcase_14 RE -
testcase_15 AC 17 ms
8,052 KB
testcase_16 AC 18 ms
7,988 KB
testcase_17 AC 17 ms
8,048 KB
testcase_18 AC 16 ms
8,132 KB
testcase_19 AC 17 ms
8,008 KB
testcase_20 RE -
testcase_21 AC 18 ms
8,032 KB
testcase_22 AC 603 ms
26,848 KB
testcase_23 AC 601 ms
26,784 KB
testcase_24 AC 752 ms
49,308 KB
testcase_25 AC 741 ms
49,300 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 1,052 ms
30,552 KB
testcase_37 AC 1,050 ms
30,688 KB
testcase_38 AC 1,030 ms
30,580 KB
testcase_39 AC 1,025 ms
30,652 KB
testcase_40 AC 1,028 ms
30,568 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)):
    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