Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <cstdio>#include <cstdlib>int n, m, q, a[105][105];int color[105], x, y, z;void work(){scanf("%d %d %d", &n, &m, &q);for (int i = 1; i <= n; i++)scanf("%d", &color[i]);for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)a[i][j] = 0;for (int i = 1; i <= m; i++)scanf("%d %d %d", &x, &y, &z), a[x][y] = a[y][x] = z;for (int i = 1; i <= q; i++){int type;scanf("%d", &type);if (type == 1)scanf("%d", &x), color[x] ^= 1;else if (type == 2)scanf("%d %d %d", &x, &y, &z), a[x][y] = a[y][x] = z;else{int s = 0;for (int j = 1; j < n; j++)for (int k = j + 1; k <= n; k++)s += (color[j] != color[k]) * a[j][k];printf("%d\n", s);