Submission #975341

# Submission time Handle Problem Language Result Execution time Memory
975341 2024-05-04T21:51:42 Z Isam Paths (BOI18_paths) C++17
23 / 100
3000 ms 8780 KB
#include<bits/stdc++.h>
using namespace std;

#define eb emplace_back

constexpr int sz = 2e5 + 5;

int n, m, k, ans, c[sz], co;

vector<int> g[sz];

inline void dfs(int node){
	
	co |= (1<<c[node]);
	
	for(auto &to : g[node]){
		if(co & (1<<c[to])) continue;
		++ans;
		dfs(to);
	}
	
	co ^= (1<<c[node]);
	
	return;
}



signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	
	cin >> n >> m >> k;
	
	for(register int i = 1; i <= n; ++i){
		cin >> c[i];
		c[i]--;
	}
	
	for(register int i = 1, u, v; i <= m; ++i){
		cin >> u >> v;
		g[u].eb(v), g[v].eb(u);
	}
	
	for(register int i = 1; i <= n; ++i){
		dfs(i);
	}
	
	cout << ans << '\n';
	
	
	return 0;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:34:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |  for(register int i = 1; i <= n; ++i){
      |                   ^
paths.cpp:39:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |  for(register int i = 1, u, v; i <= m; ++i){
      |                   ^
paths.cpp:39:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |  for(register int i = 1, u, v; i <= m; ++i){
      |                          ^
paths.cpp:39:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |  for(register int i = 1, u, v; i <= m; ++i){
      |                             ^
paths.cpp:44:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |  for(register int i = 1; i <= n; ++i){
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4968 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 5208 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3088 ms 8780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4968 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 5208 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Execution timed out 3088 ms 8780 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Execution timed out 3081 ms 6236 KB Time limit exceeded
3 Halted 0 ms 0 KB -