# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
941006 |
2024-03-08T04:58:32 Z |
phoenix0423 |
Paths (BOI18_paths) |
C++17 |
|
223 ms |
59072 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 3e5 + 5;
vector<int> adj[maxn];
int c[maxn];
int n, m, k;
int dp[maxn][32];
signed main(void){
fastio;
cin>>n>>m>>k;
for(int i = 0; i < n; i++) cin>>c[i], c[i]--;
for(int i = 0; i < m; i++){
int a, b;
cin>>a>>b;
a--, b--;
adj[a].pb(b);
adj[b].pb(a);
}
for(int i = 0; i < n; i++) dp[i][(1 << c[i])] = 1;
int ans = 0;
for(int rd = 1; rd < k; rd++){
for(int i = 0; i < n; i++){
for(int mask = 0; mask < (1 << k); mask++){
if(__builtin_popcount(mask) != rd) continue;
if(!dp[i][mask]) continue;
for(auto x : adj[i]){
if(mask & (1 << c[x])) continue;
dp[x][mask | (1 << c[x])] += dp[i][mask];
}
}
}
}
for(int i = 0; i < n; i++){
for(int mask = 1; mask < (1 << k); mask++){
if(__builtin_popcount(mask) == 1) continue;
ans += dp[i][mask];
}
}
cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9052 KB |
Output is correct |
2 |
Correct |
2 ms |
9048 KB |
Output is correct |
3 |
Correct |
2 ms |
9048 KB |
Output is correct |
4 |
Correct |
2 ms |
9048 KB |
Output is correct |
5 |
Correct |
2 ms |
9052 KB |
Output is correct |
6 |
Correct |
2 ms |
9052 KB |
Output is correct |
7 |
Correct |
2 ms |
9052 KB |
Output is correct |
8 |
Correct |
2 ms |
9052 KB |
Output is correct |
9 |
Correct |
2 ms |
9052 KB |
Output is correct |
10 |
Correct |
2 ms |
9052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
17772 KB |
Output is correct |
2 |
Correct |
46 ms |
14860 KB |
Output is correct |
3 |
Correct |
223 ms |
59072 KB |
Output is correct |
4 |
Correct |
63 ms |
21180 KB |
Output is correct |
5 |
Correct |
59 ms |
21072 KB |
Output is correct |
6 |
Incorrect |
151 ms |
47360 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9052 KB |
Output is correct |
2 |
Correct |
2 ms |
9048 KB |
Output is correct |
3 |
Correct |
2 ms |
9048 KB |
Output is correct |
4 |
Correct |
2 ms |
9048 KB |
Output is correct |
5 |
Correct |
2 ms |
9052 KB |
Output is correct |
6 |
Correct |
2 ms |
9052 KB |
Output is correct |
7 |
Correct |
2 ms |
9052 KB |
Output is correct |
8 |
Correct |
2 ms |
9052 KB |
Output is correct |
9 |
Correct |
2 ms |
9052 KB |
Output is correct |
10 |
Correct |
2 ms |
9052 KB |
Output is correct |
11 |
Correct |
50 ms |
17772 KB |
Output is correct |
12 |
Correct |
46 ms |
14860 KB |
Output is correct |
13 |
Correct |
223 ms |
59072 KB |
Output is correct |
14 |
Correct |
63 ms |
21180 KB |
Output is correct |
15 |
Correct |
59 ms |
21072 KB |
Output is correct |
16 |
Incorrect |
151 ms |
47360 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9052 KB |
Output is correct |
2 |
Incorrect |
27 ms |
10844 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |