1 #pragma comment (linker,"/STACK:1024000000,1024000000") 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 6 using namespace std; 7 8 const int maxn=50000+5; 9 10 #define ll long long 11 12 struct Edge 13 { 14 int to,next; 15 }edge[maxn<<1]; 16 int head[maxn]; 17 int tot,num; 18 int n; 19 20 void addedge(int u,int v) 21 { 22 edge[tot].to=v; 23 edge[tot].next=head[u]; 24 head[u]=tot++; 25 } 26 27 int fa[maxn]; 28 int siz[maxn]; 29 int top[maxn]; 30 int dep[maxn]; 31 int son[maxn]; 32 int val[maxn]; 33 int has[maxn]; 34 int ran[maxn]; 35 36 void dfs1(int u,int father,int d) 37 { 38 fa[u]=father; 39 siz[u]=1; 40 dep[u]=d; 41 for(int i=head[u];~i;i=edge[i].next) 42 { 43 int v=edge[i].to; 44 if(v==father) 45 continue; 46 dfs1(v,u,d+1); 47 siz[u]+=siz[v]; 48 if(son[u]==-1||siz[v]>siz[son[u]]) 49 { 50 son[u]=v; 51 } 52 } 53 } 54 55 void dfs2(int u,int tp) 56 { 57 top[u]=tp; 58 has[u]=num; 59 ran[num]=u; 60 num++; 61 if(son[u]==-1) 62 return ; 63 dfs2(son[u],tp); 64 65 for(int i=head[u];~i;i=edge[i].next) 66 { 67 int v=edge[i].to; 68 if(v==fa[u]||v==son[u]) 69 continue; 70 dfs2(v,v); 71 } 72 } 73 74 #define lson l,m,rt<<1 75 #define rson m+1,r,rt<<1|1 76 77 ll sum[maxn<<2]; 78 ll col[maxn<<2]; 79 80 void pushup(int rt) 81 { 82 sum[rt]=sum[rt<<1]+sum[rt<<1|1]; 83 } 84 85 void pushdown(int l,int r,int rt) 86 { 87 if(col[rt]) 88 { 89 int m=(l+r)>>1; 90 col[rt<<1]+=col[rt]; 91 col[rt<<1|1]+=col[rt]; 92 sum[rt<<1]+=col[rt]*(m-l+1); 93 sum[rt<<1|1]+=col[rt]*(r-m); 94 col[rt]=0; 95 } 96 } 97 98 void build(int l,int r,int rt) 99 { 100 if(l==r) 101 { 102 sum[rt]=(ll)val[ran[l]]; 103 return ; 104 } 105 106 int m=(l+r)>>1; 107 build(lson); 108 build(rson); 109 pushup(rt); 110 } 111 112 void update(int L,int R,int add,int l,int r,int rt) 113 { 114 if(L<=l&&R>=r) 115 { 116 col[rt]+=(ll)add; 117 sum[rt]+=(ll)add*(r-l+1); 118 return ; 119 } 120 121 int m=(l+r)>>1; 122 123 pushdown(l,r,rt); 124 125 if(L<=m) 126 update(L,R,add,lson); 127 if(R>m) 128 update(L,R,add,rson); 129 pushup(rt); 130 } 131 132 ll query(int p,int l,int r,int rt) 133 { 134 if(l==r) 135 { 136 return sum[rt]; 137 } 138 139 int m=(l+r)>>1; 140 pushdown(l,r,rt); 141 142 ll ret=0; 143 144 if(p<=m) 145 ret=query(p,lson); 146 else 147 ret=query(p,rson); 148 149 pushup(rt); 150 151 return ret; 152 } 153 154 void init() 155 { 156 memset(head,-1,sizeof(head)); 157 memset(son,-1,sizeof(son)); 158 memset(col,0,sizeof(col)); 159 tot=1; 160 num=1; 161 } 162 163 void change(int u,int v,int w) 164 { 165 while(top[u]!=top[v]) 166 { 167 if(dep[top[u]]<dep[top[v]]) 168 { 169 swap(u,v); 170 } 171 update(has[top[u]],has[u],w,1,n,1); 172 u=fa[top[u]]; 173 } 174 if(dep[u]>dep[v]) 175 swap(u,v); 176 update(has[u],has[v],w,1,n,1); 177 } 178 179 int main() 180 { 181 while(scanf("%d",&n)!=EOF) 182 { 183 init(); 184 185 int m,q; 186 scanf("%d%d",&m,&q); 187 188 for(int i=1;i<=n;i++) 189 scanf("%d",&val[i]); 190 191 for(int i=1;i<=m;i++) 192 { 193 int u,v; 194 scanf("%d%d",&u,&v); 195 addedge(u,v); 196 addedge(v,u); 197 } 198 199 dfs1(1,1,1); 200 dfs2(1,1); 201 202 build(1,n,1); 203 204 for(int i=1;i<=q;i++) 205 { 206 char str[5]; 207 scanf("%s",&str); 208 if(str[0]=='I'||str[0]=='D') 209 { 210 int uu,vv,ww; 211 scanf("%d%d%d",&uu,&vv,&ww); 212 213 if(str[0]=='D') 214 ww=-ww; 215 216 change(uu,vv,ww); 217 218 } 219 else 220 { 221 int uu; 222 scanf("%d",&uu); 223 printf("%lld\n",query(has[uu],1,n,1)); 224 } 225 } 226 227 } 228 229 return 0; 230 }