#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mx = 3e5+5;
int n, m, k;
int a[mx];
long long b[6][mx];
long long ans = 0;
signed main() {
cin.tie(0);ios::sync_with_stdio(0);
cin >> n >> m >> k;
for (int i=1;i<=n;i++) {
cin >> a[i];
}
for (int i=1;i<=m;i++) {
int u, v;
cin >> u >> v;
b[a[v]][u]++;
b[a[u]][v]++;
}
for (int i=1;i<=n;i++) {
b[a[i]][i] = 1;
}
assert(n < 3e5);
for (int i=1;i<=n;i++) {
long long tmp = 1;
long long cnt = 0;
for (int j=1;j<=k;j++) {
// if (a[i] == j) continue;
tmp *= b[j][i];
cnt += b[j][i];
}
cnt--;
ans += tmp * 2 + cnt;
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
8536 KB |
Output is correct |
2 |
Correct |
29 ms |
8664 KB |
Output is correct |
3 |
Runtime error |
77 ms |
25104 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Incorrect |
12 ms |
12636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |