わかさぎのブログ

プログラミング、Atcoderの勉強とか

鹿本 例題15 スプリンクラー

N,M,Q=map(int,input().split())
uv=[[0,0]]
for i in range(M):
    tmp=list(map(int,input().split()))
    uv.append(tmp)
color=[0]+list(map(int,input().split()))
s=[0]
for i in range(Q):
    tmp=list(map(int,input().split()))
    s.append(tmp)

class Point():
    def __init__(self,color):
        self.color=color
        self.to=[]
    
    def set_hen(self,to):
        self.to.append(to)
    
    def nuru(self,iro):
        self.color=iro
    
    def my_color(self):
        print(self.color)
    

ten=[Point(i) for i in color]

for i in range(1,M+1):
    l=uv[i][0]
    r=uv[i][1]
    ten[l].set_hen(r)
    ten[r].set_hen(l)

for i in range(1,Q+1):
    if s[i][0]==1:
        x=s[i][1]
        ten[x].my_color()
        for j in ten[x].to:
            ten[j].nuru(ten[x].color)
    
    if s[i][0]==2:
        x=s[i][1]
        y=s[i][2]
        ten[x].my_color()
        ten[x].nuru(y)