답안 #667044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667044 2022-11-30T08:51:17 Z Darren0724 Paths (BOI18_paths) C++17
100 / 100
401 ms 64696 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
int INF=1e18;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;cin>>n>>m>>k;
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>c[i];
        c[i]--;
    }
    vector<vector<int>> adj(n);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<vector<int>> dp((1<<k),vector<int>(n));
    for(int i=0;i<n;i++){
        dp[(1<<c[i])][i]=1;
    }
    for(int i=1;i<(1<<k);i++){
        for(int j=0;j<n;j++){
            if(i&(1<<c[j])){
                for(int e:adj[j]){
                    dp[i][j]+=dp[i^(1<<c[j])][e];
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<(1<<k);i++){
        for(int j=0;j<n;j++){
            ans+=dp[i][j];
        }
    }
    cout<<ans-n<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 228 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 10736 KB Output is correct
2 Correct 45 ms 9676 KB Output is correct
3 Correct 302 ms 45740 KB Output is correct
4 Correct 88 ms 13992 KB Output is correct
5 Correct 80 ms 13408 KB Output is correct
6 Correct 173 ms 33532 KB Output is correct
7 Correct 246 ms 45764 KB Output is correct
8 Correct 270 ms 46364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 228 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 60 ms 10736 KB Output is correct
12 Correct 45 ms 9676 KB Output is correct
13 Correct 302 ms 45740 KB Output is correct
14 Correct 88 ms 13992 KB Output is correct
15 Correct 80 ms 13408 KB Output is correct
16 Correct 173 ms 33532 KB Output is correct
17 Correct 246 ms 45764 KB Output is correct
18 Correct 270 ms 46364 KB Output is correct
19 Correct 60 ms 10720 KB Output is correct
20 Correct 44 ms 9676 KB Output is correct
21 Correct 237 ms 45744 KB Output is correct
22 Correct 93 ms 13816 KB Output is correct
23 Correct 84 ms 13456 KB Output is correct
24 Correct 153 ms 33544 KB Output is correct
25 Correct 256 ms 45884 KB Output is correct
26 Correct 247 ms 46276 KB Output is correct
27 Correct 50 ms 9704 KB Output is correct
28 Correct 76 ms 13064 KB Output is correct
29 Correct 351 ms 64544 KB Output is correct
30 Correct 257 ms 37700 KB Output is correct
31 Correct 248 ms 37760 KB Output is correct
32 Correct 401 ms 64696 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 21 ms 3284 KB Output is correct
3 Correct 18 ms 3256 KB Output is correct
4 Correct 77 ms 15280 KB Output is correct
5 Correct 54 ms 15804 KB Output is correct
6 Correct 139 ms 34148 KB Output is correct
7 Correct 17 ms 3224 KB Output is correct
8 Correct 81 ms 21612 KB Output is correct
9 Correct 73 ms 22024 KB Output is correct
10 Correct 90 ms 21696 KB Output is correct
11 Correct 58 ms 18516 KB Output is correct
12 Correct 60 ms 26508 KB Output is correct
13 Correct 57 ms 18664 KB Output is correct
14 Correct 115 ms 34240 KB Output is correct
15 Correct 114 ms 34220 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct