MSBOP 2015 Round2B register

Ended

Participants:6187

Verdict:AC | RE
Submitted:2015-04-26 14:32:25

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<cstdio>
#include<cstring>
#define N 100001
#define LL long long
int sex[N];
int tot,head[N];
struct Link{
    int y,z,next;
}   e[N<<1];
LL ans;
int n,m,q;
void addEdge(int x,int y,int z){
    e[tot].y=y,e[tot].z=z,e[tot].next=head[x],head[x]=tot++;
    e[tot].y=x,e[tot].z=z,e[tot].next=head[y],head[y]=tot++;
}
int main(){
    int T,tt=0;
    int i,k,x,y,z,tmp;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d",&n,&m,&q);
        for(i=1;i<=n;++i){
            scanf("%d",&sex[i]);
        }
        tot=0;
        memset(head,-1,sizeof(head));
        ans=0;
        for(i=0;i<m;++i){
            scanf("%d%d%d",&x,&y,&z);
            addEdge(x,y,z);
            if(sex[x]!=sex[y]) ans+=(LL)z;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX