Submission #63174

# Submission time Handle Problem Language Result Execution time Memory
63174 2018-08-01T03:56:28 Z 김세빈(#1833) Paths (BOI18_paths) C++11
100 / 100
920 ms 171240 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll dp[2][303030][33];
ll S[303030], E[303030], C[303030];
ll n, m, k, ans;

int main()
{
	ll i, j, x, s, e;
	
	scanf("%lld%lld%lld", &n, &m, &k);
	
	for(i=1; i<=n; i++){
		scanf("%lld", C+i); C[i] --;
		dp[1][i][1<<C[i]] = 1;
	}
	
	for(i=1; i<=m; i++){
		scanf("%lld%lld", S+i, E+i);
	}
	
	for(i=1; i<k; i++){
		for(j=1; j<=m; j++){
			s = S[j], e = E[j];
			for(x=0; x<(1<<k); x++){
				if(x & (1 << C[s])) dp[0][s][x] += dp[1][e][x - (1 << C[s])];
				if(x & (1 << C[e])) dp[0][e][x] += dp[1][s][x - (1 << C[e])];
			}
		}
		
		for(j=1; j<=n; j++){
			for(x=0; x<(1<<k); x++){
				ans += dp[0][j][x];
				dp[1][j][x] = dp[0][j][x];
				dp[0][j][x] = 0;
			}
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", C+i); C[i] --;
   ~~~~~^~~~~~~~~~~~~
paths.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", S+i, E+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 524 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 3 ms 684 KB Output is correct
6 Correct 2 ms 704 KB Output is correct
7 Correct 3 ms 704 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 8004 KB Output is correct
2 Correct 108 ms 8004 KB Output is correct
3 Correct 569 ms 162704 KB Output is correct
4 Correct 124 ms 162704 KB Output is correct
5 Correct 108 ms 162704 KB Output is correct
6 Correct 482 ms 162704 KB Output is correct
7 Correct 481 ms 162784 KB Output is correct
8 Correct 550 ms 162812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 524 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 3 ms 684 KB Output is correct
6 Correct 2 ms 704 KB Output is correct
7 Correct 3 ms 704 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 128 ms 8004 KB Output is correct
12 Correct 108 ms 8004 KB Output is correct
13 Correct 569 ms 162704 KB Output is correct
14 Correct 124 ms 162704 KB Output is correct
15 Correct 108 ms 162704 KB Output is correct
16 Correct 482 ms 162704 KB Output is correct
17 Correct 481 ms 162784 KB Output is correct
18 Correct 550 ms 162812 KB Output is correct
19 Correct 111 ms 162812 KB Output is correct
20 Correct 107 ms 162812 KB Output is correct
21 Correct 489 ms 162812 KB Output is correct
22 Correct 148 ms 162812 KB Output is correct
23 Correct 108 ms 162812 KB Output is correct
24 Correct 497 ms 162812 KB Output is correct
25 Correct 547 ms 168796 KB Output is correct
26 Correct 512 ms 171240 KB Output is correct
27 Correct 182 ms 171240 KB Output is correct
28 Correct 210 ms 171240 KB Output is correct
29 Correct 920 ms 171240 KB Output is correct
30 Correct 575 ms 171240 KB Output is correct
31 Correct 505 ms 171240 KB Output is correct
32 Correct 753 ms 171240 KB Output is correct
33 Correct 2 ms 171240 KB Output is correct
34 Correct 2 ms 171240 KB Output is correct
35 Correct 3 ms 171240 KB Output is correct
36 Correct 2 ms 171240 KB Output is correct
37 Correct 2 ms 171240 KB Output is correct
38 Correct 3 ms 171240 KB Output is correct
39 Correct 3 ms 171240 KB Output is correct
40 Correct 3 ms 171240 KB Output is correct
41 Correct 3 ms 171240 KB Output is correct
42 Correct 3 ms 171240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 171240 KB Output is correct
2 Correct 80 ms 171240 KB Output is correct
3 Correct 37 ms 171240 KB Output is correct
4 Correct 192 ms 171240 KB Output is correct
5 Correct 158 ms 171240 KB Output is correct
6 Correct 422 ms 171240 KB Output is correct
7 Correct 43 ms 171240 KB Output is correct
8 Correct 211 ms 171240 KB Output is correct
9 Correct 195 ms 171240 KB Output is correct
10 Correct 216 ms 171240 KB Output is correct
11 Correct 281 ms 171240 KB Output is correct
12 Correct 329 ms 171240 KB Output is correct
13 Correct 228 ms 171240 KB Output is correct
14 Correct 326 ms 171240 KB Output is correct
15 Correct 350 ms 171240 KB Output is correct
16 Correct 2 ms 171240 KB Output is correct
17 Correct 2 ms 171240 KB Output is correct
18 Correct 2 ms 171240 KB Output is correct
19 Correct 3 ms 171240 KB Output is correct
20 Correct 2 ms 171240 KB Output is correct
21 Correct 2 ms 171240 KB Output is correct
22 Correct 3 ms 171240 KB Output is correct
23 Correct 4 ms 171240 KB Output is correct
24 Correct 3 ms 171240 KB Output is correct
25 Correct 2 ms 171240 KB Output is correct