Submission #94180

# Submission time Handle Problem Language Result Execution time Memory
94180 2019-01-16T12:32:32 Z gs14004 Paths (BOI18_paths) C++17
100 / 100
503 ms 56692 KB
#include<bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 300005;
const int mod = 1e9 + 7;

int n, m, k, a[MAXN];
vector<int> gph[MAXN];
lint dp[32][MAXN];

int main(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
		a[i]--;
		dp[1 << a[i]][i] = 1;
	}
	for(int i=0; i<m; i++){
		int s, e;
		scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	lint ret = 0;
	for(int i=2; i<(1<<k); i++){
		if(i == (i & -i)) continue;
		for(int j=1; j<=n; j++){
			if((i >> a[j]) & 1){
				for(auto &k : gph[j]){
					dp[i][j] += dp[i ^ (1 << a[j])][k];
				}
			}
			ret += dp[i][j];
		}
	}
	cout << ret << endl;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
paths.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
paths.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&s,&e);
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 21 ms 7544 KB Output is correct
2 Correct 7 ms 7544 KB Output is correct
3 Correct 7 ms 7416 KB Output is correct
4 Correct 6 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 7 ms 7544 KB Output is correct
7 Correct 6 ms 7516 KB Output is correct
8 Correct 6 ms 7544 KB Output is correct
9 Correct 7 ms 7420 KB Output is correct
10 Correct 7 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 14200 KB Output is correct
2 Correct 73 ms 13296 KB Output is correct
3 Correct 338 ms 37768 KB Output is correct
4 Correct 138 ms 16084 KB Output is correct
5 Correct 127 ms 15452 KB Output is correct
6 Correct 248 ms 30336 KB Output is correct
7 Correct 310 ms 37880 KB Output is correct
8 Correct 340 ms 38468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 7544 KB Output is correct
2 Correct 7 ms 7544 KB Output is correct
3 Correct 7 ms 7416 KB Output is correct
4 Correct 6 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 7 ms 7544 KB Output is correct
7 Correct 6 ms 7516 KB Output is correct
8 Correct 6 ms 7544 KB Output is correct
9 Correct 7 ms 7420 KB Output is correct
10 Correct 7 ms 7416 KB Output is correct
11 Correct 92 ms 14200 KB Output is correct
12 Correct 73 ms 13296 KB Output is correct
13 Correct 338 ms 37768 KB Output is correct
14 Correct 138 ms 16084 KB Output is correct
15 Correct 127 ms 15452 KB Output is correct
16 Correct 248 ms 30336 KB Output is correct
17 Correct 310 ms 37880 KB Output is correct
18 Correct 340 ms 38468 KB Output is correct
19 Correct 87 ms 14200 KB Output is correct
20 Correct 67 ms 13304 KB Output is correct
21 Correct 283 ms 37880 KB Output is correct
22 Correct 122 ms 15992 KB Output is correct
23 Correct 113 ms 15484 KB Output is correct
24 Correct 214 ms 30400 KB Output is correct
25 Correct 259 ms 37880 KB Output is correct
26 Correct 309 ms 38520 KB Output is correct
27 Correct 73 ms 13304 KB Output is correct
28 Correct 101 ms 15652 KB Output is correct
29 Correct 385 ms 56688 KB Output is correct
30 Correct 251 ms 35564 KB Output is correct
31 Correct 285 ms 34288 KB Output is correct
32 Correct 503 ms 56692 KB Output is correct
33 Correct 7 ms 7544 KB Output is correct
34 Correct 7 ms 7416 KB Output is correct
35 Correct 6 ms 7416 KB Output is correct
36 Correct 6 ms 7416 KB Output is correct
37 Correct 6 ms 7416 KB Output is correct
38 Correct 6 ms 7416 KB Output is correct
39 Correct 6 ms 7416 KB Output is correct
40 Correct 6 ms 7420 KB Output is correct
41 Correct 7 ms 7420 KB Output is correct
42 Correct 6 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7544 KB Output is correct
2 Correct 30 ms 9524 KB Output is correct
3 Correct 28 ms 9208 KB Output is correct
4 Correct 72 ms 17400 KB Output is correct
5 Correct 54 ms 18160 KB Output is correct
6 Correct 114 ms 36348 KB Output is correct
7 Correct 28 ms 9336 KB Output is correct
8 Correct 97 ms 23724 KB Output is correct
9 Correct 82 ms 24432 KB Output is correct
10 Correct 103 ms 23532 KB Output is correct
11 Correct 80 ms 23028 KB Output is correct
12 Correct 88 ms 28400 KB Output is correct
13 Correct 78 ms 21864 KB Output is correct
14 Correct 144 ms 36344 KB Output is correct
15 Correct 147 ms 36508 KB Output is correct
16 Correct 7 ms 7516 KB Output is correct
17 Correct 7 ms 7544 KB Output is correct
18 Correct 7 ms 7416 KB Output is correct
19 Correct 7 ms 7416 KB Output is correct
20 Correct 6 ms 7416 KB Output is correct
21 Correct 6 ms 7416 KB Output is correct
22 Correct 6 ms 7544 KB Output is correct
23 Correct 6 ms 7544 KB Output is correct
24 Correct 8 ms 7464 KB Output is correct
25 Correct 6 ms 7416 KB Output is correct