Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int cas, T, n, m, q;int s[110];int d[110][110];int t0[110], t1[110];int main(){scanf("%d", &T);while(T--){scanf("%d%d%d", &n, &m, &q);for (int i = 1; i <= n; i++){scanf("%d", s+i);t0[i] = t1[i] = 0;}for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++) d[i][j] = 0;int x, y, z, ans = 0;for (int i = 0; i < m; i++){scanf("%d%d%d", &x, &y, &z);if (s[x] == s[y]){t0[x] += z;t0[y] += z;}else{t1[x] += z;t1[y] += z;ans += z;