# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1112778 |
2024-11-14T19:47:57 Z |
kojac |
Paths (BOI18_paths) |
C++17 |
|
644 ms |
1048576 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define MAXN (int)(3e5+10)
ll dp[MAXN][7][70], n, m, k, c[MAXN];
vector<ll> g[MAXN];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k;
for(int i = 1; i <= n; i++) cin >> c[i];
for(int i = 0; i < m; i++){
ll x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
for(int i = 1; i <= n; i++){
ll aux = (1<<c[i]);
dp[i][1][aux] = 1;
}
ll aux;
for(int i = 2; i <= k; i++){
for(int j = 1; j <= n; j++){
for(int bm = 0; bm < (1<<(k+1)); bm++){
if((bm & (1<<c[j])) == 0) continue;
aux = bm-(1<<c[j]);
for(auto u : g[j]){
dp[j][i][bm] += dp[u][i-1][aux];
}
}
}
}
ll ans = 0;
for(int i = 2; i <= k; i++){
for(int j = 1; j <= n; j++){
for(int aux = 0; aux < (1<<(k+1)); aux++){
ans += dp[j][i][aux];
}
}
}
// cout << dp[1][3][6] << " AQQ\n";
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10832 KB |
Output is correct |
2 |
Correct |
2 ms |
10832 KB |
Output is correct |
3 |
Correct |
3 ms |
10844 KB |
Output is correct |
4 |
Correct |
2 ms |
10832 KB |
Output is correct |
5 |
Correct |
2 ms |
10832 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
10908 KB |
Output is correct |
8 |
Correct |
2 ms |
11000 KB |
Output is correct |
9 |
Correct |
3 ms |
10832 KB |
Output is correct |
10 |
Correct |
3 ms |
10832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
36384 KB |
Output is correct |
2 |
Correct |
40 ms |
20048 KB |
Output is correct |
3 |
Runtime error |
644 ms |
1048576 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10832 KB |
Output is correct |
2 |
Correct |
2 ms |
10832 KB |
Output is correct |
3 |
Correct |
3 ms |
10844 KB |
Output is correct |
4 |
Correct |
2 ms |
10832 KB |
Output is correct |
5 |
Correct |
2 ms |
10832 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
10908 KB |
Output is correct |
8 |
Correct |
2 ms |
11000 KB |
Output is correct |
9 |
Correct |
3 ms |
10832 KB |
Output is correct |
10 |
Correct |
3 ms |
10832 KB |
Output is correct |
11 |
Correct |
62 ms |
36384 KB |
Output is correct |
12 |
Correct |
40 ms |
20048 KB |
Output is correct |
13 |
Runtime error |
644 ms |
1048576 KB |
Execution killed with signal 9 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10832 KB |
Output is correct |
2 |
Correct |
33 ms |
14928 KB |
Output is correct |
3 |
Correct |
16 ms |
14928 KB |
Output is correct |
4 |
Correct |
272 ms |
396684 KB |
Output is correct |
5 |
Correct |
270 ms |
397224 KB |
Output is correct |
6 |
Correct |
495 ms |
396876 KB |
Output is correct |
7 |
Correct |
21 ms |
14928 KB |
Output is correct |
8 |
Correct |
339 ms |
396932 KB |
Output is correct |
9 |
Correct |
314 ms |
397132 KB |
Output is correct |
10 |
Correct |
341 ms |
396988 KB |
Output is correct |
11 |
Correct |
258 ms |
204224 KB |
Output is correct |
12 |
Correct |
364 ms |
300552 KB |
Output is correct |
13 |
Correct |
259 ms |
204148 KB |
Output is correct |
14 |
Correct |
485 ms |
396872 KB |
Output is correct |
15 |
Correct |
466 ms |
396988 KB |
Output is correct |
16 |
Correct |
3 ms |
10832 KB |
Output is correct |
17 |
Correct |
3 ms |
10832 KB |
Output is correct |
18 |
Correct |
3 ms |
10832 KB |
Output is correct |
19 |
Correct |
2 ms |
10832 KB |
Output is correct |
20 |
Correct |
3 ms |
11088 KB |
Output is correct |
21 |
Correct |
2 ms |
11000 KB |
Output is correct |
22 |
Correct |
3 ms |
10832 KB |
Output is correct |
23 |
Correct |
3 ms |
11008 KB |
Output is correct |
24 |
Correct |
2 ms |
10832 KB |
Output is correct |
25 |
Correct |
2 ms |
10832 KB |
Output is correct |