Submission #1009405

# Submission time Handle Problem Language Result Execution time Memory
1009405 2024-06-27T13:23:32 Z alexdd Paths (BOI18_paths) C++17
100 / 100
259 ms 73192 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int color[300005];
long long dp[5][32][300005];
vector<int> con[300005];
signed main()
{
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>color[i];
        color[i]--;
        dp[0][(1<<color[i])][i]=1;
    }
    int u,v;
    for(int i=1;i<=m;i++)
    {
        cin>>u>>v;
        con[u].push_back(v);
        con[v].push_back(u);
    }
    for(int pas=1;pas<k;pas++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int mask=(1<<color[i]);mask<(1<<k);mask++)
            {
                if(!dp[pas-1][mask][i])
                    continue;
                for(auto x:con[i])
                {
                    if(!((1<<color[x])&mask))
                        dp[pas][mask+(1<<color[x])][x] += dp[pas-1][mask][i];
                }
            }
        }
    }
    long long rez=0;
    for(int pas=1;pas<k;pas++)
        for(int i=1;i<=n;i++)
            for(int mask=0;mask<(1<<k);mask++)
                rez += dp[pas][mask][i];
    cout<<rez;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 41820 KB Output is correct
2 Correct 5 ms 41736 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 12932 KB Output is correct
6 Correct 4 ms 31580 KB Output is correct
7 Correct 5 ms 39808 KB Output is correct
8 Correct 4 ms 41820 KB Output is correct
9 Correct 2 ms 17244 KB Output is correct
10 Correct 4 ms 25180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 31584 KB Output is correct
2 Correct 87 ms 31112 KB Output is correct
3 Correct 200 ms 50512 KB Output is correct
4 Correct 130 ms 24660 KB Output is correct
5 Correct 116 ms 20564 KB Output is correct
6 Correct 172 ms 46580 KB Output is correct
7 Correct 209 ms 50260 KB Output is correct
8 Correct 209 ms 51028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 41820 KB Output is correct
2 Correct 5 ms 41736 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 12932 KB Output is correct
6 Correct 4 ms 31580 KB Output is correct
7 Correct 5 ms 39808 KB Output is correct
8 Correct 4 ms 41820 KB Output is correct
9 Correct 2 ms 17244 KB Output is correct
10 Correct 4 ms 25180 KB Output is correct
11 Correct 106 ms 31584 KB Output is correct
12 Correct 87 ms 31112 KB Output is correct
13 Correct 200 ms 50512 KB Output is correct
14 Correct 130 ms 24660 KB Output is correct
15 Correct 116 ms 20564 KB Output is correct
16 Correct 172 ms 46580 KB Output is correct
17 Correct 209 ms 50260 KB Output is correct
18 Correct 209 ms 51028 KB Output is correct
19 Correct 97 ms 31572 KB Output is correct
20 Correct 95 ms 30940 KB Output is correct
21 Correct 199 ms 50432 KB Output is correct
22 Correct 130 ms 24660 KB Output is correct
23 Correct 108 ms 20540 KB Output is correct
24 Correct 166 ms 46536 KB Output is correct
25 Correct 188 ms 50304 KB Output is correct
26 Correct 185 ms 50940 KB Output is correct
27 Correct 95 ms 47440 KB Output is correct
28 Correct 114 ms 48884 KB Output is correct
29 Correct 258 ms 73192 KB Output is correct
30 Correct 193 ms 61384 KB Output is correct
31 Correct 168 ms 60016 KB Output is correct
32 Correct 259 ms 72440 KB Output is correct
33 Correct 6 ms 41820 KB Output is correct
34 Correct 5 ms 41820 KB Output is correct
35 Correct 3 ms 25176 KB Output is correct
36 Correct 2 ms 16988 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 4 ms 31440 KB Output is correct
39 Correct 5 ms 39772 KB Output is correct
40 Correct 4 ms 41820 KB Output is correct
41 Correct 3 ms 17244 KB Output is correct
42 Correct 3 ms 25220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 17500 KB Output is correct
2 Correct 42 ms 50312 KB Output is correct
3 Correct 31 ms 26964 KB Output is correct
4 Correct 62 ms 35416 KB Output is correct
5 Correct 52 ms 34232 KB Output is correct
6 Correct 93 ms 63564 KB Output is correct
7 Correct 34 ms 43652 KB Output is correct
8 Correct 80 ms 51916 KB Output is correct
9 Correct 62 ms 42588 KB Output is correct
10 Correct 64 ms 42444 KB Output is correct
11 Correct 71 ms 54020 KB Output is correct
12 Correct 64 ms 48376 KB Output is correct
13 Correct 69 ms 52552 KB Output is correct
14 Correct 94 ms 64716 KB Output is correct
15 Correct 92 ms 63384 KB Output is correct
16 Correct 5 ms 41816 KB Output is correct
17 Correct 4 ms 41820 KB Output is correct
18 Correct 3 ms 25180 KB Output is correct
19 Correct 2 ms 16988 KB Output is correct
20 Correct 2 ms 12892 KB Output is correct
21 Correct 4 ms 31580 KB Output is correct
22 Correct 4 ms 39772 KB Output is correct
23 Correct 5 ms 41848 KB Output is correct
24 Correct 2 ms 17240 KB Output is correct
25 Correct 3 ms 25180 KB Output is correct