답안 #391125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391125 2021-04-18T00:01:31 Z nikatamliani Paths (BOI18_paths) C++14
100 / 100
406 ms 56772 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 3e5+10;
int a[N], color[N], n, m, k;
vector<int> edges[N];
long long dp[32][N];
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> k;
	for(int i = 0; i < n; ++i) {
		cin >> color[i];
		--color[i];
	}
	for(int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	for(int i = 0; i < n; ++i) {
		dp[1 << color[i]][i] = 1;
	}
	for(int mask = 1; mask < (1 << k); ++mask) {
		for(int x = 0; x < n; ++x) {
			int bit = color[x];
			if(mask >> bit & 1) {
				int submask = mask ^ (1 << bit);
				for(int i : edges[x]) {
					dp[mask][x] += dp[submask][i];
				}
			}
		}
	}
	long long ans = -n;
	for(int mask = 0; mask < (1 << k); ++mask) {
		for(int x = 0; x < n; ++x) {
			ans += dp[mask][x];
		}
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7500 KB Output is correct
2 Correct 4 ms 7500 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 5 ms 7364 KB Output is correct
5 Correct 5 ms 7372 KB Output is correct
6 Correct 4 ms 7504 KB Output is correct
7 Correct 5 ms 7500 KB Output is correct
8 Correct 5 ms 7500 KB Output is correct
9 Correct 4 ms 7372 KB Output is correct
10 Correct 4 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 14300 KB Output is correct
2 Correct 60 ms 13204 KB Output is correct
3 Correct 294 ms 37780 KB Output is correct
4 Correct 108 ms 16068 KB Output is correct
5 Correct 98 ms 15424 KB Output is correct
6 Correct 194 ms 30312 KB Output is correct
7 Correct 299 ms 37792 KB Output is correct
8 Correct 305 ms 38448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7500 KB Output is correct
2 Correct 4 ms 7500 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 5 ms 7364 KB Output is correct
5 Correct 5 ms 7372 KB Output is correct
6 Correct 4 ms 7504 KB Output is correct
7 Correct 5 ms 7500 KB Output is correct
8 Correct 5 ms 7500 KB Output is correct
9 Correct 4 ms 7372 KB Output is correct
10 Correct 4 ms 7372 KB Output is correct
11 Correct 75 ms 14300 KB Output is correct
12 Correct 60 ms 13204 KB Output is correct
13 Correct 294 ms 37780 KB Output is correct
14 Correct 108 ms 16068 KB Output is correct
15 Correct 98 ms 15424 KB Output is correct
16 Correct 194 ms 30312 KB Output is correct
17 Correct 299 ms 37792 KB Output is correct
18 Correct 305 ms 38448 KB Output is correct
19 Correct 71 ms 14144 KB Output is correct
20 Correct 62 ms 13264 KB Output is correct
21 Correct 308 ms 37908 KB Output is correct
22 Correct 97 ms 15992 KB Output is correct
23 Correct 102 ms 15476 KB Output is correct
24 Correct 197 ms 30260 KB Output is correct
25 Correct 288 ms 37776 KB Output is correct
26 Correct 310 ms 38496 KB Output is correct
27 Correct 63 ms 13380 KB Output is correct
28 Correct 91 ms 15800 KB Output is correct
29 Correct 406 ms 56544 KB Output is correct
30 Correct 225 ms 35512 KB Output is correct
31 Correct 241 ms 34380 KB Output is correct
32 Correct 404 ms 56772 KB Output is correct
33 Correct 5 ms 7500 KB Output is correct
34 Correct 5 ms 7500 KB Output is correct
35 Correct 4 ms 7372 KB Output is correct
36 Correct 5 ms 7372 KB Output is correct
37 Correct 4 ms 7376 KB Output is correct
38 Correct 5 ms 7500 KB Output is correct
39 Correct 5 ms 7500 KB Output is correct
40 Correct 5 ms 7504 KB Output is correct
41 Correct 5 ms 7380 KB Output is correct
42 Correct 4 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 25 ms 9560 KB Output is correct
3 Correct 23 ms 9292 KB Output is correct
4 Correct 71 ms 17372 KB Output is correct
5 Correct 58 ms 18108 KB Output is correct
6 Correct 133 ms 36248 KB Output is correct
7 Correct 24 ms 9356 KB Output is correct
8 Correct 104 ms 23736 KB Output is correct
9 Correct 68 ms 24512 KB Output is correct
10 Correct 82 ms 23548 KB Output is correct
11 Correct 74 ms 22820 KB Output is correct
12 Correct 74 ms 28344 KB Output is correct
13 Correct 70 ms 21816 KB Output is correct
14 Correct 136 ms 36364 KB Output is correct
15 Correct 147 ms 36504 KB Output is correct
16 Correct 5 ms 7500 KB Output is correct
17 Correct 5 ms 7504 KB Output is correct
18 Correct 5 ms 7372 KB Output is correct
19 Correct 5 ms 7376 KB Output is correct
20 Correct 5 ms 7372 KB Output is correct
21 Correct 5 ms 7504 KB Output is correct
22 Correct 5 ms 7500 KB Output is correct
23 Correct 4 ms 7504 KB Output is correct
24 Correct 5 ms 7372 KB Output is correct
25 Correct 5 ms 7372 KB Output is correct