# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
399353 |
2021-05-05T15:35:47 Z |
iulia13 |
Paths (BOI18_paths) |
C++14 |
|
1012 ms |
66848 KB |
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
const int nmax = 3e5 + 5;
int color[nmax];
vector<vector<ll>> dp;
vector <int> g[nmax];
///dp[nod][msk] -> din nodul nod un lant care are culorile din msk o sg data
ll dfs(ll nod, ll msk = 0)
{
if (dp[nod][msk] != -1)
return dp[nod][msk];
if (msk & (1 << color[nod]))
{
dp[nod][msk] = 0;
return 0;
}
dp[nod][msk] = 1;
for (auto x : g[nod])
dp[nod][msk] += dfs(x, msk + (1 << color[nod]));
return dp[nod][msk];
}
int main()
{
int n, m, k, i;
ll ans = 0;
cin >> n >> m >> k;
for (i = 0; i < n; i++)
cin >> color[i], color[i]--;
while(m--)
{
int a, b;
cin >> a >> b;
a--; b--;
g[a].push_back(b);
g[b].push_back(a);
}
dp.resize(n);
for (i = 0; i < n; i++)
dp[i].resize((1 << k), -1);
for (i = 0; i < n; i++)
ans += dfs(i);
cout << ans - n;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7244 KB |
Output is correct |
2 |
Correct |
5 ms |
7244 KB |
Output is correct |
3 |
Correct |
6 ms |
7244 KB |
Output is correct |
4 |
Correct |
6 ms |
7244 KB |
Output is correct |
5 |
Correct |
5 ms |
7244 KB |
Output is correct |
6 |
Correct |
6 ms |
7244 KB |
Output is correct |
7 |
Correct |
6 ms |
7360 KB |
Output is correct |
8 |
Correct |
6 ms |
7244 KB |
Output is correct |
9 |
Correct |
5 ms |
7244 KB |
Output is correct |
10 |
Correct |
5 ms |
7244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
221 ms |
11320 KB |
Output is correct |
2 |
Correct |
163 ms |
11244 KB |
Output is correct |
3 |
Correct |
720 ms |
47812 KB |
Output is correct |
4 |
Correct |
259 ms |
13968 KB |
Output is correct |
5 |
Correct |
269 ms |
13444 KB |
Output is correct |
6 |
Correct |
612 ms |
35944 KB |
Output is correct |
7 |
Correct |
775 ms |
47796 KB |
Output is correct |
8 |
Correct |
685 ms |
48360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7244 KB |
Output is correct |
2 |
Correct |
5 ms |
7244 KB |
Output is correct |
3 |
Correct |
6 ms |
7244 KB |
Output is correct |
4 |
Correct |
6 ms |
7244 KB |
Output is correct |
5 |
Correct |
5 ms |
7244 KB |
Output is correct |
6 |
Correct |
6 ms |
7244 KB |
Output is correct |
7 |
Correct |
6 ms |
7360 KB |
Output is correct |
8 |
Correct |
6 ms |
7244 KB |
Output is correct |
9 |
Correct |
5 ms |
7244 KB |
Output is correct |
10 |
Correct |
5 ms |
7244 KB |
Output is correct |
11 |
Correct |
221 ms |
11320 KB |
Output is correct |
12 |
Correct |
163 ms |
11244 KB |
Output is correct |
13 |
Correct |
720 ms |
47812 KB |
Output is correct |
14 |
Correct |
259 ms |
13968 KB |
Output is correct |
15 |
Correct |
269 ms |
13444 KB |
Output is correct |
16 |
Correct |
612 ms |
35944 KB |
Output is correct |
17 |
Correct |
775 ms |
47796 KB |
Output is correct |
18 |
Correct |
685 ms |
48360 KB |
Output is correct |
19 |
Correct |
203 ms |
11448 KB |
Output is correct |
20 |
Correct |
165 ms |
11532 KB |
Output is correct |
21 |
Correct |
733 ms |
47808 KB |
Output is correct |
22 |
Correct |
281 ms |
13928 KB |
Output is correct |
23 |
Correct |
222 ms |
13372 KB |
Output is correct |
24 |
Correct |
573 ms |
35980 KB |
Output is correct |
25 |
Correct |
724 ms |
47856 KB |
Output is correct |
26 |
Correct |
624 ms |
48456 KB |
Output is correct |
27 |
Correct |
186 ms |
11448 KB |
Output is correct |
28 |
Correct |
256 ms |
13288 KB |
Output is correct |
29 |
Correct |
1012 ms |
66716 KB |
Output is correct |
30 |
Correct |
834 ms |
39020 KB |
Output is correct |
31 |
Correct |
851 ms |
39168 KB |
Output is correct |
32 |
Correct |
914 ms |
66848 KB |
Output is correct |
33 |
Correct |
5 ms |
7244 KB |
Output is correct |
34 |
Correct |
5 ms |
7372 KB |
Output is correct |
35 |
Correct |
5 ms |
7244 KB |
Output is correct |
36 |
Correct |
5 ms |
7348 KB |
Output is correct |
37 |
Correct |
5 ms |
7244 KB |
Output is correct |
38 |
Correct |
6 ms |
7244 KB |
Output is correct |
39 |
Correct |
6 ms |
7344 KB |
Output is correct |
40 |
Correct |
5 ms |
7244 KB |
Output is correct |
41 |
Correct |
5 ms |
7244 KB |
Output is correct |
42 |
Correct |
5 ms |
7244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7248 KB |
Output is correct |
2 |
Correct |
81 ms |
9136 KB |
Output is correct |
3 |
Correct |
58 ms |
9020 KB |
Output is correct |
4 |
Correct |
198 ms |
21272 KB |
Output is correct |
5 |
Correct |
159 ms |
22084 KB |
Output is correct |
6 |
Correct |
308 ms |
40176 KB |
Output is correct |
7 |
Correct |
64 ms |
9024 KB |
Output is correct |
8 |
Correct |
252 ms |
27612 KB |
Output is correct |
9 |
Correct |
171 ms |
28280 KB |
Output is correct |
10 |
Correct |
213 ms |
28168 KB |
Output is correct |
11 |
Correct |
263 ms |
24512 KB |
Output is correct |
12 |
Correct |
183 ms |
32756 KB |
Output is correct |
13 |
Correct |
247 ms |
24528 KB |
Output is correct |
14 |
Correct |
315 ms |
40144 KB |
Output is correct |
15 |
Correct |
225 ms |
40232 KB |
Output is correct |
16 |
Correct |
5 ms |
7244 KB |
Output is correct |
17 |
Correct |
5 ms |
7276 KB |
Output is correct |
18 |
Correct |
5 ms |
7244 KB |
Output is correct |
19 |
Correct |
5 ms |
7344 KB |
Output is correct |
20 |
Correct |
4 ms |
7244 KB |
Output is correct |
21 |
Correct |
5 ms |
7244 KB |
Output is correct |
22 |
Correct |
5 ms |
7312 KB |
Output is correct |
23 |
Correct |
5 ms |
7372 KB |
Output is correct |
24 |
Correct |
5 ms |
7244 KB |
Output is correct |
25 |
Correct |
5 ms |
7244 KB |
Output is correct |