답안 #1009407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1009407 2024-06-27T13:26:22 Z alexdd Paths (BOI18_paths) C++17
100 / 100
403 ms 141396 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);
    }
    long long rez=0;
    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(!(mask&(1<<color[i])))
                    continue;
                for(auto x:con[i])
                    dp[pas][mask][i] += dp[pas-1][mask-(1<<color[i])][x];
                rez += dp[pas][mask][i];
            }
        }
    }
    cout<<rez;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 19292 KB Output is correct
2 Correct 3 ms 19292 KB Output is correct
3 Correct 2 ms 17032 KB Output is correct
4 Correct 2 ms 14940 KB Output is correct
5 Correct 1 ms 12892 KB Output is correct
6 Correct 3 ms 19292 KB Output is correct
7 Correct 3 ms 19292 KB Output is correct
8 Correct 3 ms 19292 KB Output is correct
9 Correct 2 ms 15448 KB Output is correct
10 Correct 2 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 21164 KB Output is correct
2 Correct 74 ms 20596 KB Output is correct
3 Correct 293 ms 64336 KB Output is correct
4 Correct 114 ms 19956 KB Output is correct
5 Correct 117 ms 17236 KB Output is correct
6 Correct 173 ms 50216 KB Output is correct
7 Correct 227 ms 64324 KB Output is correct
8 Correct 239 ms 64976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 19292 KB Output is correct
2 Correct 3 ms 19292 KB Output is correct
3 Correct 2 ms 17032 KB Output is correct
4 Correct 2 ms 14940 KB Output is correct
5 Correct 1 ms 12892 KB Output is correct
6 Correct 3 ms 19292 KB Output is correct
7 Correct 3 ms 19292 KB Output is correct
8 Correct 3 ms 19292 KB Output is correct
9 Correct 2 ms 15448 KB Output is correct
10 Correct 2 ms 16988 KB Output is correct
11 Correct 92 ms 21164 KB Output is correct
12 Correct 74 ms 20596 KB Output is correct
13 Correct 293 ms 64336 KB Output is correct
14 Correct 114 ms 19956 KB Output is correct
15 Correct 117 ms 17236 KB Output is correct
16 Correct 173 ms 50216 KB Output is correct
17 Correct 227 ms 64324 KB Output is correct
18 Correct 239 ms 64976 KB Output is correct
19 Correct 129 ms 21108 KB Output is correct
20 Correct 74 ms 20560 KB Output is correct
21 Correct 241 ms 64336 KB Output is correct
22 Correct 118 ms 20048 KB Output is correct
23 Correct 109 ms 17232 KB Output is correct
24 Correct 180 ms 50112 KB Output is correct
25 Correct 248 ms 64316 KB Output is correct
26 Correct 238 ms 65108 KB Output is correct
27 Correct 81 ms 23124 KB Output is correct
28 Correct 106 ms 26448 KB Output is correct
29 Correct 403 ms 141396 KB Output is correct
30 Correct 249 ms 83968 KB Output is correct
31 Correct 225 ms 80580 KB Output is correct
32 Correct 373 ms 141396 KB Output is correct
33 Correct 2 ms 19292 KB Output is correct
34 Correct 2 ms 19348 KB Output is correct
35 Correct 2 ms 16988 KB Output is correct
36 Correct 2 ms 14940 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 3 ms 19292 KB Output is correct
39 Correct 3 ms 19292 KB Output is correct
40 Correct 2 ms 19292 KB Output is correct
41 Correct 2 ms 15196 KB Output is correct
42 Correct 2 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15704 KB Output is correct
2 Correct 36 ms 23644 KB Output is correct
3 Correct 34 ms 18260 KB Output is correct
4 Correct 67 ms 34872 KB Output is correct
5 Correct 59 ms 35664 KB Output is correct
6 Correct 206 ms 128004 KB Output is correct
7 Correct 31 ms 20564 KB Output is correct
8 Correct 96 ms 61404 KB Output is correct
9 Correct 74 ms 62156 KB Output is correct
10 Correct 87 ms 59624 KB Output is correct
11 Correct 105 ms 74580 KB Output is correct
12 Correct 99 ms 92748 KB Output is correct
13 Correct 121 ms 67904 KB Output is correct
14 Correct 208 ms 128076 KB Output is correct
15 Correct 212 ms 128152 KB Output is correct
16 Correct 2 ms 19288 KB Output is correct
17 Correct 3 ms 19292 KB Output is correct
18 Correct 2 ms 16988 KB Output is correct
19 Correct 2 ms 14940 KB Output is correct
20 Correct 2 ms 12892 KB Output is correct
21 Correct 3 ms 19292 KB Output is correct
22 Correct 3 ms 19292 KB Output is correct
23 Correct 3 ms 19292 KB Output is correct
24 Correct 3 ms 15196 KB Output is correct
25 Correct 2 ms 16984 KB Output is correct