답안 #173519

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173519 2020-01-04T12:10:54 Z rzbt Paths (BOI18_paths) C++14
100 / 100
549 ms 107512 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 300005
typedef long long ll;


using namespace std;

vector<ll> niz[MAXN];
ll dp[MAXN][35];
ll koji[MAXN];
ll n,m,k;
ll res=0;
int main()
{
    scanf("%lld %lld %lld", &n, &m, &k);
    for(ll i=1;i<=n;i++){
        ll t;
        scanf("%lld", &t);
        t--;
        dp[i][1<<t]=1;
        koji[i]=1<<t;
    }
    for(ll i=1;i<=m;i++){
        ll t1,t2;
        scanf("%lld %lld", &t1, &t2);
        niz[t1].pb(t2);
        niz[t2].pb(t1);
    }
    for(ll j=1;j<(1<<k);j++){
        for(ll i=1;i<=n;i++){
            if(!(koji[i]&j))continue;
            for(auto x:niz[i]){
                dp[i][j]+=dp[x][j-koji[i]];

            }
            res+=dp[i][j];
            //printf("  %lld %lld   %lld\n",i,j,dp[i][j]);
        }
    }
    printf("%lld",res-n);
    return 0;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &t);
         ~~~~~^~~~~~~~~~~~
paths.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &t1, &t2);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 10 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7416 KB Output is correct
9 Correct 8 ms 7420 KB Output is correct
10 Correct 9 ms 7420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 18720 KB Output is correct
2 Correct 89 ms 16792 KB Output is correct
3 Correct 425 ms 106872 KB Output is correct
4 Correct 174 ms 27256 KB Output is correct
5 Correct 172 ms 27412 KB Output is correct
6 Correct 311 ms 76652 KB Output is correct
7 Correct 450 ms 107224 KB Output is correct
8 Correct 477 ms 107508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 10 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7416 KB Output is correct
9 Correct 8 ms 7420 KB Output is correct
10 Correct 9 ms 7420 KB Output is correct
11 Correct 119 ms 18720 KB Output is correct
12 Correct 89 ms 16792 KB Output is correct
13 Correct 425 ms 106872 KB Output is correct
14 Correct 174 ms 27256 KB Output is correct
15 Correct 172 ms 27412 KB Output is correct
16 Correct 311 ms 76652 KB Output is correct
17 Correct 450 ms 107224 KB Output is correct
18 Correct 477 ms 107508 KB Output is correct
19 Correct 119 ms 18808 KB Output is correct
20 Correct 98 ms 16908 KB Output is correct
21 Correct 442 ms 106896 KB Output is correct
22 Correct 179 ms 27256 KB Output is correct
23 Correct 171 ms 27420 KB Output is correct
24 Correct 307 ms 76644 KB Output is correct
25 Correct 419 ms 106872 KB Output is correct
26 Correct 428 ms 107512 KB Output is correct
27 Correct 95 ms 16888 KB Output is correct
28 Correct 136 ms 21064 KB Output is correct
29 Correct 549 ms 106988 KB Output is correct
30 Correct 368 ms 62480 KB Output is correct
31 Correct 330 ms 62572 KB Output is correct
32 Correct 542 ms 107048 KB Output is correct
33 Correct 9 ms 7588 KB Output is correct
34 Correct 8 ms 7416 KB Output is correct
35 Correct 8 ms 7416 KB Output is correct
36 Correct 8 ms 7416 KB Output is correct
37 Correct 8 ms 7420 KB Output is correct
38 Correct 8 ms 7416 KB Output is correct
39 Correct 8 ms 7416 KB Output is correct
40 Correct 8 ms 7416 KB Output is correct
41 Correct 8 ms 7420 KB Output is correct
42 Correct 9 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 38 ms 10416 KB Output is correct
3 Correct 34 ms 10360 KB Output is correct
4 Correct 118 ms 40440 KB Output is correct
5 Correct 96 ms 40848 KB Output is correct
6 Correct 166 ms 40376 KB Output is correct
7 Correct 35 ms 10488 KB Output is correct
8 Correct 133 ms 40440 KB Output is correct
9 Correct 113 ms 40876 KB Output is correct
10 Correct 126 ms 41076 KB Output is correct
11 Correct 96 ms 25200 KB Output is correct
12 Correct 116 ms 33000 KB Output is correct
13 Correct 98 ms 25584 KB Output is correct
14 Correct 184 ms 40440 KB Output is correct
15 Correct 199 ms 40568 KB Output is correct
16 Correct 8 ms 7416 KB Output is correct
17 Correct 9 ms 7448 KB Output is correct
18 Correct 8 ms 7416 KB Output is correct
19 Correct 9 ms 7544 KB Output is correct
20 Correct 8 ms 7416 KB Output is correct
21 Correct 8 ms 7416 KB Output is correct
22 Correct 8 ms 7416 KB Output is correct
23 Correct 8 ms 7416 KB Output is correct
24 Correct 9 ms 7416 KB Output is correct
25 Correct 8 ms 7416 KB Output is correct