Submission #231322

# Submission time Handle Problem Language Result Execution time Memory
231322 2020-05-13T11:15:36 Z DodgeBallMan Paths (BOI18_paths) C++14
100 / 100
440 ms 116056 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 10;
int n, m, k, col[N];
long long dp[N][40], ans;
vector<int> g[N];

long long solve( int u, int bit ) {
    long long &ret = dp[u][bit];
    if( ret != -1 ) return ret;
    ret = 1;
    for( int v : g[u] ) if( ( 1<<col[v] ) & bit ) ret += solve( v, bit - ( 1<<col[v] ) );
    return ret;
}

int main()
{
    memset( dp, -1, sizeof dp );
    scanf("%d %d %d",&n,&m,&k);
    for( int i = 1 ; i <= n ; i++ ) {
        scanf("%d",&col[i]);
        col[i]--;
    }
    for( int i = 1, a, b ; i <= m ; i++ ) {
        scanf("%d %d",&a,&b);
        g[a].emplace_back( b ), g[b].emplace_back( a );
    }
    for( int i = 1 ; i <= n ; i++ ) ans += solve( i, (1<<k)-(1<<col[i])-1 ) - 1;
    printf("%lld",ans);
    return 0;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&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("%d",&col[i]);
         ~~~~~^~~~~~~~~~~~~~
paths.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 52 ms 101368 KB Output is correct
2 Correct 51 ms 101240 KB Output is correct
3 Correct 52 ms 101240 KB Output is correct
4 Correct 52 ms 101240 KB Output is correct
5 Correct 52 ms 101240 KB Output is correct
6 Correct 52 ms 101240 KB Output is correct
7 Correct 52 ms 101368 KB Output is correct
8 Correct 50 ms 101368 KB Output is correct
9 Correct 51 ms 101244 KB Output is correct
10 Correct 52 ms 101240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 105208 KB Output is correct
2 Correct 151 ms 104896 KB Output is correct
3 Correct 398 ms 115064 KB Output is correct
4 Correct 198 ms 109320 KB Output is correct
5 Correct 180 ms 109176 KB Output is correct
6 Correct 305 ms 113256 KB Output is correct
7 Correct 395 ms 115456 KB Output is correct
8 Correct 382 ms 115960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 101368 KB Output is correct
2 Correct 51 ms 101240 KB Output is correct
3 Correct 52 ms 101240 KB Output is correct
4 Correct 52 ms 101240 KB Output is correct
5 Correct 52 ms 101240 KB Output is correct
6 Correct 52 ms 101240 KB Output is correct
7 Correct 52 ms 101368 KB Output is correct
8 Correct 50 ms 101368 KB Output is correct
9 Correct 51 ms 101244 KB Output is correct
10 Correct 52 ms 101240 KB Output is correct
11 Correct 152 ms 105208 KB Output is correct
12 Correct 151 ms 104896 KB Output is correct
13 Correct 398 ms 115064 KB Output is correct
14 Correct 198 ms 109320 KB Output is correct
15 Correct 180 ms 109176 KB Output is correct
16 Correct 305 ms 113256 KB Output is correct
17 Correct 395 ms 115456 KB Output is correct
18 Correct 382 ms 115960 KB Output is correct
19 Correct 157 ms 107908 KB Output is correct
20 Correct 140 ms 107128 KB Output is correct
21 Correct 406 ms 115320 KB Output is correct
22 Correct 180 ms 109304 KB Output is correct
23 Correct 182 ms 109180 KB Output is correct
24 Correct 316 ms 113480 KB Output is correct
25 Correct 405 ms 115376 KB Output is correct
26 Correct 386 ms 116056 KB Output is correct
27 Correct 153 ms 107128 KB Output is correct
28 Correct 187 ms 108668 KB Output is correct
29 Correct 440 ms 115576 KB Output is correct
30 Correct 362 ms 111852 KB Output is correct
31 Correct 366 ms 111724 KB Output is correct
32 Correct 430 ms 115412 KB Output is correct
33 Correct 52 ms 101240 KB Output is correct
34 Correct 51 ms 101240 KB Output is correct
35 Correct 52 ms 101368 KB Output is correct
36 Correct 50 ms 101240 KB Output is correct
37 Correct 50 ms 101240 KB Output is correct
38 Correct 51 ms 101316 KB Output is correct
39 Correct 51 ms 101240 KB Output is correct
40 Correct 52 ms 101368 KB Output is correct
41 Correct 55 ms 101240 KB Output is correct
42 Correct 51 ms 101240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 101284 KB Output is correct
2 Correct 93 ms 102520 KB Output is correct
3 Correct 81 ms 102520 KB Output is correct
4 Correct 138 ms 104568 KB Output is correct
5 Correct 115 ms 105328 KB Output is correct
6 Correct 158 ms 104568 KB Output is correct
7 Correct 86 ms 102520 KB Output is correct
8 Correct 140 ms 104600 KB Output is correct
9 Correct 117 ms 105328 KB Output is correct
10 Correct 133 ms 105332 KB Output is correct
11 Correct 137 ms 103412 KB Output is correct
12 Correct 117 ms 104304 KB Output is correct
13 Correct 127 ms 103544 KB Output is correct
14 Correct 159 ms 104580 KB Output is correct
15 Correct 150 ms 104696 KB Output is correct
16 Correct 51 ms 101240 KB Output is correct
17 Correct 51 ms 101240 KB Output is correct
18 Correct 52 ms 101240 KB Output is correct
19 Correct 51 ms 101240 KB Output is correct
20 Correct 52 ms 101240 KB Output is correct
21 Correct 51 ms 101240 KB Output is correct
22 Correct 51 ms 101240 KB Output is correct
23 Correct 52 ms 101368 KB Output is correct
24 Correct 53 ms 101240 KB Output is correct
25 Correct 52 ms 101240 KB Output is correct