Submission #864333

# Submission time Handle Problem Language Result Execution time Memory
864333 2023-10-22T14:23:19 Z maks007 Paths (BOI18_paths) C++14
0 / 100
110 ms 796 KB
#include "bits/stdc++.h"

using namespace std;

#define int long long

vector <int> color;
vector <vector <int>> cntColor;

signed main () {
	int n, m, k;
	cin >> n >> m >> k;
	color.resize(n);
	cntColor.resize(n, vector <int> (k + 1, 0));
	for(int i = 0; i < n; i ++) cin >> color[i];
	for(int i = 0, u, v; i < m; i ++) {
		cin >> u >> v;
		u --, v --;
		cntColor[u][color[v]] ++;
		cntColor[v][color[u]] ++;
	}
	
	int ans = 0;
	for(int color2 = 1; color2 <= k; color2 ++) {
		for(int i = 0; i < n; i ++) {
			if(color[i] == color2) {
				for(int color1 = 1; color1 <= k; color1 ++) {
					if(color1 == color2) continue;
					ans += cntColor[i][color1];
					if(k == 2) continue;
					for(int color3 = color1 + 1; color3 <= k; color3 ++) {
						ans += 2 * (cntColor[i][color1] * cntColor[i][color3]);
					}
				}
			}
		}
  	}
  	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 28 ms 448 KB Output isn't correct
3 Halted 0 ms 0 KB -