답안 #476414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476414 2021-09-26T12:59:08 Z AdamGS Paths (BOI18_paths) C++14
100 / 100
996 ms 100432 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=3e5+7;
vector<int>V[LIM];
int T[LIM], dp[LIM][1<<5];
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	rep(i, n) {
		cin >> T[i]; --T[i];
		dp[i][1<<T[i]]=1;
	}
	rep(i, m) {
		int a, b;
		cin >> a >> b; --a; --b;
		V[a].pb(b);
		V[b].pb(a);
	}
	int ans=0;
	for(int i=1; i<(1<<k); ++i) {
		rep(j, n) {
			if(__builtin_popcount(i)>1) ans+=dp[j][i];
			for(auto l : V[j]) if(!(i&(1<<T[l]))) {
				dp[l][i+(1<<T[l])]+=dp[j][i];
			}
		}
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7372 KB Output is correct
4 Correct 4 ms 7372 KB Output is correct
5 Correct 4 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 4 ms 7372 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 4 ms 7372 KB Output is correct
10 Correct 4 ms 7244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 15740 KB Output is correct
2 Correct 86 ms 14816 KB Output is correct
3 Correct 590 ms 99476 KB Output is correct
4 Correct 149 ms 26564 KB Output is correct
5 Correct 152 ms 26688 KB Output is correct
6 Correct 354 ms 71872 KB Output is correct
7 Correct 531 ms 99848 KB Output is correct
8 Correct 500 ms 100356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7372 KB Output is correct
4 Correct 4 ms 7372 KB Output is correct
5 Correct 4 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 4 ms 7372 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 4 ms 7372 KB Output is correct
10 Correct 4 ms 7244 KB Output is correct
11 Correct 104 ms 15740 KB Output is correct
12 Correct 86 ms 14816 KB Output is correct
13 Correct 590 ms 99476 KB Output is correct
14 Correct 149 ms 26564 KB Output is correct
15 Correct 152 ms 26688 KB Output is correct
16 Correct 354 ms 71872 KB Output is correct
17 Correct 531 ms 99848 KB Output is correct
18 Correct 500 ms 100356 KB Output is correct
19 Correct 97 ms 18600 KB Output is correct
20 Correct 90 ms 16964 KB Output is correct
21 Correct 576 ms 99872 KB Output is correct
22 Correct 162 ms 26544 KB Output is correct
23 Correct 129 ms 26648 KB Output is correct
24 Correct 363 ms 71936 KB Output is correct
25 Correct 500 ms 99844 KB Output is correct
26 Correct 529 ms 100432 KB Output is correct
27 Correct 120 ms 16852 KB Output is correct
28 Correct 172 ms 20808 KB Output is correct
29 Correct 996 ms 99928 KB Output is correct
30 Correct 517 ms 58876 KB Output is correct
31 Correct 559 ms 58932 KB Output is correct
32 Correct 937 ms 99864 KB Output is correct
33 Correct 4 ms 7372 KB Output is correct
34 Correct 4 ms 7372 KB Output is correct
35 Correct 4 ms 7372 KB Output is correct
36 Correct 4 ms 7372 KB Output is correct
37 Correct 4 ms 7372 KB Output is correct
38 Correct 4 ms 7372 KB Output is correct
39 Correct 5 ms 7372 KB Output is correct
40 Correct 5 ms 7372 KB Output is correct
41 Correct 4 ms 7372 KB Output is correct
42 Correct 4 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7244 KB Output is correct
2 Correct 67 ms 9568 KB Output is correct
3 Correct 30 ms 9708 KB Output is correct
4 Correct 144 ms 36816 KB Output is correct
5 Correct 82 ms 37092 KB Output is correct
6 Correct 390 ms 36708 KB Output is correct
7 Correct 40 ms 9676 KB Output is correct
8 Correct 236 ms 36704 KB Output is correct
9 Correct 150 ms 37056 KB Output is correct
10 Correct 196 ms 37236 KB Output is correct
11 Correct 179 ms 22916 KB Output is correct
12 Correct 175 ms 29876 KB Output is correct
13 Correct 239 ms 23232 KB Output is correct
14 Correct 329 ms 36712 KB Output is correct
15 Correct 412 ms 36804 KB Output is correct
16 Correct 5 ms 7372 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 5 ms 7372 KB Output is correct
19 Correct 5 ms 7372 KB Output is correct
20 Correct 5 ms 7372 KB Output is correct
21 Correct 5 ms 7372 KB Output is correct
22 Correct 5 ms 7372 KB Output is correct
23 Correct 4 ms 7372 KB Output is correct
24 Correct 5 ms 7372 KB Output is correct
25 Correct 4 ms 7288 KB Output is correct