Submission #63184

# Submission time Handle Problem Language Result Execution time Memory
63184 2018-08-01T04:31:19 Z khsoo01 Paths (BOI18_paths) C++11
100 / 100
741 ms 55884 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N = 300005;

ll n, m, k, a[N], dt[1<<5][N], ans;

vector<ll> adj[N];

int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		a[i]--;
	}
	for(ll i=1;i<=m;i++) {
		ll A, B;
		scanf("%lld%lld",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	for(ll x=1;x<(1<<k);x++) {
		for(ll i=1;i<=n;i++) {
			ll j = (1<<a[i]);
			if(!(j & x)) continue;
			if(j == x) dt[x][i] = 1;
			for(auto &T : adj[i]) {
				dt[x][i] += dt[x-j][T];
			}
			ans += dt[x][i];
		}
	}
	printf("%lld\n",ans-n);
}

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("%lld%lld%lld",&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("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
paths.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&A,&B);
   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 9 ms 7620 KB Output is correct
3 Correct 10 ms 7620 KB Output is correct
4 Correct 11 ms 7620 KB Output is correct
5 Correct 9 ms 7620 KB Output is correct
6 Correct 8 ms 7688 KB Output is correct
7 Correct 9 ms 7688 KB Output is correct
8 Correct 9 ms 7688 KB Output is correct
9 Correct 9 ms 7688 KB Output is correct
10 Correct 10 ms 7688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 15260 KB Output is correct
2 Correct 113 ms 15260 KB Output is correct
3 Correct 558 ms 36964 KB Output is correct
4 Correct 300 ms 36964 KB Output is correct
5 Correct 230 ms 36964 KB Output is correct
6 Correct 295 ms 36964 KB Output is correct
7 Correct 448 ms 36964 KB Output is correct
8 Correct 537 ms 37628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 9 ms 7620 KB Output is correct
3 Correct 10 ms 7620 KB Output is correct
4 Correct 11 ms 7620 KB Output is correct
5 Correct 9 ms 7620 KB Output is correct
6 Correct 8 ms 7688 KB Output is correct
7 Correct 9 ms 7688 KB Output is correct
8 Correct 9 ms 7688 KB Output is correct
9 Correct 9 ms 7688 KB Output is correct
10 Correct 10 ms 7688 KB Output is correct
11 Correct 160 ms 15260 KB Output is correct
12 Correct 113 ms 15260 KB Output is correct
13 Correct 558 ms 36964 KB Output is correct
14 Correct 300 ms 36964 KB Output is correct
15 Correct 230 ms 36964 KB Output is correct
16 Correct 295 ms 36964 KB Output is correct
17 Correct 448 ms 36964 KB Output is correct
18 Correct 537 ms 37628 KB Output is correct
19 Correct 158 ms 37628 KB Output is correct
20 Correct 122 ms 37628 KB Output is correct
21 Correct 556 ms 37628 KB Output is correct
22 Correct 285 ms 37628 KB Output is correct
23 Correct 267 ms 37628 KB Output is correct
24 Correct 464 ms 37628 KB Output is correct
25 Correct 557 ms 37628 KB Output is correct
26 Correct 524 ms 37628 KB Output is correct
27 Correct 154 ms 37628 KB Output is correct
28 Correct 197 ms 37628 KB Output is correct
29 Correct 741 ms 55884 KB Output is correct
30 Correct 475 ms 55884 KB Output is correct
31 Correct 485 ms 55884 KB Output is correct
32 Correct 687 ms 55884 KB Output is correct
33 Correct 10 ms 55884 KB Output is correct
34 Correct 10 ms 55884 KB Output is correct
35 Correct 11 ms 55884 KB Output is correct
36 Correct 11 ms 55884 KB Output is correct
37 Correct 9 ms 55884 KB Output is correct
38 Correct 11 ms 55884 KB Output is correct
39 Correct 11 ms 55884 KB Output is correct
40 Correct 10 ms 55884 KB Output is correct
41 Correct 11 ms 55884 KB Output is correct
42 Correct 9 ms 55884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 55884 KB Output is correct
2 Correct 44 ms 55884 KB Output is correct
3 Correct 40 ms 55884 KB Output is correct
4 Correct 187 ms 55884 KB Output is correct
5 Correct 124 ms 55884 KB Output is correct
6 Correct 357 ms 55884 KB Output is correct
7 Correct 42 ms 55884 KB Output is correct
8 Correct 203 ms 55884 KB Output is correct
9 Correct 153 ms 55884 KB Output is correct
10 Correct 172 ms 55884 KB Output is correct
11 Correct 189 ms 55884 KB Output is correct
12 Correct 184 ms 55884 KB Output is correct
13 Correct 138 ms 55884 KB Output is correct
14 Correct 365 ms 55884 KB Output is correct
15 Correct 355 ms 55884 KB Output is correct
16 Correct 10 ms 55884 KB Output is correct
17 Correct 9 ms 55884 KB Output is correct
18 Correct 8 ms 55884 KB Output is correct
19 Correct 10 ms 55884 KB Output is correct
20 Correct 11 ms 55884 KB Output is correct
21 Correct 11 ms 55884 KB Output is correct
22 Correct 10 ms 55884 KB Output is correct
23 Correct 10 ms 55884 KB Output is correct
24 Correct 11 ms 55884 KB Output is correct
25 Correct 11 ms 55884 KB Output is correct