Submission #864394

# Submission time Handle Problem Language Result Execution time Memory
864394 2023-10-22T17:29:58 Z iskhakkutbilim Paths (BOI18_paths) C++17
23 / 100
3000 ms 17748 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 3e5;
int n, m, col[N+1];
int k;
vector<int> g[N+1];
int ans;

int used[N+10], used_c[N+10];

void dfs(int v){
	used[v] = 1, used_c[col[v]] = 1;
	ans++;
	for(int to : g[v]){
		if(used[to] == 0 && used_c[col[to]] == 0){
			dfs(to);
		}	
	}
	used[v] = 0, used_c[col[v]] = 0;
}

main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for(int i = 1;i <= n; i++){
		cin >> col[i];
	}
	for(int i = 0;i < m; i++){
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	
	for(int i = 1;i <= n; i++){
		dfs(i);
		ans--;
		for(int j = 1;j <= n; j++){
			used[j] = 0;
		}
		for(int j = 0;j <= k; j++) used_c[j] = 0;
	}
	
	cout << ans;
	return 0;
}

Compilation message

paths.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10584 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10584 KB Output is correct
5 Correct 2 ms 10588 KB Output is correct
6 Correct 2 ms 10584 KB Output is correct
7 Correct 2 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 2 ms 10720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 17748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10584 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10584 KB Output is correct
5 Correct 2 ms 10588 KB Output is correct
6 Correct 2 ms 10584 KB Output is correct
7 Correct 2 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 2 ms 10720 KB Output is correct
11 Execution timed out 3053 ms 17748 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Execution timed out 3071 ms 12852 KB Time limit exceeded
3 Halted 0 ms 0 KB -