Submission #926965

# Submission time Handle Problem Language Result Execution time Memory
926965 2024-02-14T05:57:40 Z vjudge1 Paths (BOI18_paths) C++17
23 / 100
3000 ms 15132 KB
#include<bits/stdc++.h>

using namespace std;


const int N = (int)3e5+3;
const int MOD = (int)1e6+3;

int n, m, k, a[N];
vector<int> g[N];
bool used[N];
int ans = 0;

void dfs(int v) {
	used[a[v]] = 1;
	ans++;
	for(auto to : g[v]) {
		if(!used[a[to]]) {
			dfs(to);
		}
	}
	used[a[v]] = 0;
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(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;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i) {
		dfs(i);
	}
	cout << ans-n;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8540 KB Output is correct
6 Correct 2 ms 8540 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1915 ms 15132 KB Output is correct
2 Execution timed out 3064 ms 14420 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8540 KB Output is correct
6 Correct 2 ms 8540 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1915 ms 15132 KB Output is correct
12 Execution timed out 3064 ms 14420 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Execution timed out 3026 ms 10328 KB Time limit exceeded
3 Halted 0 ms 0 KB -