Submission #951578

# Submission time Handle Problem Language Result Execution time Memory
951578 2024-03-22T07:02:24 Z mocha Paths (BOI18_paths) C++14
0 / 100
4 ms 9048 KB
#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5+5;

int n, m, k;
int a[mx];
long long b[3][mx];
long long ans = 0;

int 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++) {
		long long tmp = 1;
		long long cnt = 0;
		for (int j=1;j<=k;j++) {
			if (a[i] == a[j]) continue;
			tmp *= b[j][i];
			cnt += b[j][i];
		}
		ans += tmp + cnt;
	}
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 9048 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -