답안 #595422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595422 2022-07-13T17:42:28 Z UncoolAnon Paths (BOI18_paths) C++14
100 / 100
407 ms 64612 KB
//18:08
#include <bits/stdc++.h> 
#define int long long 
using namespace std; 
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr); 
	int n,m,k; 
	cin>>n>>m>>k; 
	vector<int> adj[n+1],color(n+1); 
	for(int i=1;i<=n;i++) cin>>color[i],color[i]--; 
	while(m--){
		int a,b; 
		cin>>a>>b; 
		adj[a].push_back(b); 
		adj[b].push_back(a); 
	}
	int B=(1LL<<k); 
	vector<vector<int>> dp(B,vector<int>(n+1,-1)); 
	for(auto&x:dp) for(int&y:x) y=-1; 
	function<int(int,int)> dfs=[&](int mask,int a){
		if(dp[mask][a]!=-1) return dp[mask][a];
		int answer=1; 
		for(int&x:adj[a]){
			if(((1LL<<color[x])&mask)==0){
				answer+=dfs((1LL<<color[x])|mask,x); 
			}
		}
		return dp[mask][a]=answer; 
	}; 
	int answer=0; 
	for(int i=1;i<=n;i++) answer+=dfs((1LL<<color[i]),i); 
	cout<<answer-n; 
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 10780 KB Output is correct
2 Correct 59 ms 9616 KB Output is correct
3 Correct 327 ms 45784 KB Output is correct
4 Correct 92 ms 13820 KB Output is correct
5 Correct 88 ms 13388 KB Output is correct
6 Correct 218 ms 33560 KB Output is correct
7 Correct 303 ms 45920 KB Output is correct
8 Correct 308 ms 46372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 76 ms 10780 KB Output is correct
12 Correct 59 ms 9616 KB Output is correct
13 Correct 327 ms 45784 KB Output is correct
14 Correct 92 ms 13820 KB Output is correct
15 Correct 88 ms 13388 KB Output is correct
16 Correct 218 ms 33560 KB Output is correct
17 Correct 303 ms 45920 KB Output is correct
18 Correct 308 ms 46372 KB Output is correct
19 Correct 76 ms 10776 KB Output is correct
20 Correct 57 ms 9696 KB Output is correct
21 Correct 312 ms 45836 KB Output is correct
22 Correct 121 ms 13920 KB Output is correct
23 Correct 94 ms 13424 KB Output is correct
24 Correct 207 ms 33624 KB Output is correct
25 Correct 317 ms 45732 KB Output is correct
26 Correct 332 ms 46384 KB Output is correct
27 Correct 73 ms 9680 KB Output is correct
28 Correct 98 ms 13140 KB Output is correct
29 Correct 407 ms 64612 KB Output is correct
30 Correct 282 ms 37608 KB Output is correct
31 Correct 307 ms 37708 KB Output is correct
32 Correct 380 ms 64612 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 324 KB Output is correct
37 Correct 0 ms 320 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 320 KB Output is correct
42 Correct 0 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 46 ms 3272 KB Output is correct
3 Correct 26 ms 3240 KB Output is correct
4 Correct 65 ms 15332 KB Output is correct
5 Correct 45 ms 15684 KB Output is correct
6 Correct 106 ms 34220 KB Output is correct
7 Correct 36 ms 3276 KB Output is correct
8 Correct 88 ms 21576 KB Output is correct
9 Correct 54 ms 21976 KB Output is correct
10 Correct 64 ms 21712 KB Output is correct
11 Correct 90 ms 18604 KB Output is correct
12 Correct 58 ms 26528 KB Output is correct
13 Correct 107 ms 18612 KB Output is correct
14 Correct 104 ms 34188 KB Output is correct
15 Correct 96 ms 34252 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct