# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
348994 |
2021-01-16T09:38:58 Z |
blue |
Paths (BOI18_paths) |
C++17 |
|
3000 ms |
37996 KB |
#include <iostream>
#include <vector>
using namespace std;
int N, M, K;
int col[300001];
vector<int> edge[300001];
vector< vector<int> > dp;
int curr;
int count1[33];
void dfs(int u, int mask)
{
if(mask & (1 << col[u])) return;
mask += (1 << col[u]);
dp[curr][mask - (1 << col[curr])] += 1;
if(count1[mask] < 3)
for(int v: edge[u]) dfs(v, mask);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N >> M >> K;
for(int i = 1; i <= N; i++)
{
cin >> col[i];
col[i]--;
}
int a, b;
for(int i = 1; i <= M; i++)
{
cin >> a >> b;
edge[a].push_back(b);
edge[b].push_back(a);
}
count1[0] = 0;
for(int i = 1; i <= 32; i++) count1[i] = count1[i/2] + (i % 2);
dp = vector< vector<int> >(N+1, vector<int>((1 << K), 0));
for(curr = 1; curr <= N; curr++) dfs(curr, 0);
// for(int i = 1; i <= N; i++)
// {
// for(int j = 0; j < (1 << K); j++) cout << dp[i][j] << ' ';
// cout << '\n';
// }
long long res = 0;
for(int i = 1; i <= N; i++)
{
for(int mask = 1; mask < (1 << K); mask++)
{
res += dp[i][mask];
}
}
cout << res << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
7404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
511 ms |
11372 KB |
Output is correct |
2 |
Correct |
2601 ms |
11116 KB |
Output is correct |
3 |
Correct |
369 ms |
37996 KB |
Output is correct |
4 |
Correct |
153 ms |
13164 KB |
Output is correct |
5 |
Correct |
102 ms |
13036 KB |
Output is correct |
6 |
Execution timed out |
3065 ms |
29520 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
7404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7404 KB |
Output is correct |
2 |
Incorrect |
775 ms |
8684 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |