Submission #148109

# Submission time Handle Problem Language Result Execution time Memory
148109 2019-08-31T13:57:56 Z WhipppedCream Paths (BOI18_paths) C++17
100 / 100
481 ms 60924 KB
//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
const int maxn = 3e5+5;
int dp[maxn][33];
vi adj[maxn];
int col[maxn];
int ways(int u, int bit)
{
    ll res = 1;
    if(dp[u][bit] != -1) return dp[u][bit];
    for(auto v : adj[u])
    {
        if((1<<col[v]) & bit) continue;
        res += ways(v, bit | (1<<col[v]));
    }
    return dp[u][bit] = res;
}
int main()
{
    memset(dp, -1, sizeof dp);
    int n, m, k; scanf("%d %d %d", &n, &m, &k);
    for(int i = 1; i<= n; i++) scanf("%d", col+i);
    for(int i = 1; i<= n; i++) col[i]--;
    while(m--)
    {
        int u, v; scanf("%d %d", &u, &v);
        adj[u].pb(v); adj[v].pb(u);
    }
    ll ret = 0;
    for(int i = 1; i<= n; i++) ret += ways(i, 1<<col[i]);
    printf("%lld\n", ret-n);
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:27:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n, m, k; scanf("%d %d %d", &n, &m, &k);
                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:28:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i<= n; i++) scanf("%d", col+i);
                                ~~~~~^~~~~~~~~~~~~
paths.cpp:32:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int u, v; scanf("%d %d", &u, &v);
                   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 41 ms 46072 KB Output is correct
2 Correct 42 ms 46072 KB Output is correct
3 Correct 41 ms 46072 KB Output is correct
4 Correct 41 ms 46200 KB Output is correct
5 Correct 41 ms 46072 KB Output is correct
6 Correct 42 ms 46096 KB Output is correct
7 Correct 41 ms 46144 KB Output is correct
8 Correct 41 ms 46200 KB Output is correct
9 Correct 41 ms 46172 KB Output is correct
10 Correct 41 ms 46072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 52600 KB Output is correct
2 Correct 125 ms 51932 KB Output is correct
3 Correct 442 ms 60196 KB Output is correct
4 Correct 189 ms 54084 KB Output is correct
5 Correct 180 ms 54012 KB Output is correct
6 Correct 309 ms 58264 KB Output is correct
7 Correct 411 ms 60152 KB Output is correct
8 Correct 398 ms 60924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 46072 KB Output is correct
2 Correct 42 ms 46072 KB Output is correct
3 Correct 41 ms 46072 KB Output is correct
4 Correct 41 ms 46200 KB Output is correct
5 Correct 41 ms 46072 KB Output is correct
6 Correct 42 ms 46096 KB Output is correct
7 Correct 41 ms 46144 KB Output is correct
8 Correct 41 ms 46200 KB Output is correct
9 Correct 41 ms 46172 KB Output is correct
10 Correct 41 ms 46072 KB Output is correct
11 Correct 150 ms 52600 KB Output is correct
12 Correct 125 ms 51932 KB Output is correct
13 Correct 442 ms 60196 KB Output is correct
14 Correct 189 ms 54084 KB Output is correct
15 Correct 180 ms 54012 KB Output is correct
16 Correct 309 ms 58264 KB Output is correct
17 Correct 411 ms 60152 KB Output is correct
18 Correct 398 ms 60924 KB Output is correct
19 Correct 169 ms 52600 KB Output is correct
20 Correct 126 ms 51832 KB Output is correct
21 Correct 402 ms 60424 KB Output is correct
22 Correct 186 ms 54008 KB Output is correct
23 Correct 180 ms 54088 KB Output is correct
24 Correct 315 ms 58256 KB Output is correct
25 Correct 439 ms 60288 KB Output is correct
26 Correct 409 ms 60920 KB Output is correct
27 Correct 142 ms 51848 KB Output is correct
28 Correct 177 ms 53364 KB Output is correct
29 Correct 481 ms 60340 KB Output is correct
30 Correct 364 ms 56656 KB Output is correct
31 Correct 366 ms 56820 KB Output is correct
32 Correct 469 ms 60108 KB Output is correct
33 Correct 41 ms 46072 KB Output is correct
34 Correct 41 ms 46072 KB Output is correct
35 Correct 42 ms 46328 KB Output is correct
36 Correct 42 ms 46072 KB Output is correct
37 Correct 42 ms 46152 KB Output is correct
38 Correct 41 ms 46072 KB Output is correct
39 Correct 43 ms 46072 KB Output is correct
40 Correct 42 ms 46200 KB Output is correct
41 Correct 42 ms 46208 KB Output is correct
42 Correct 42 ms 46072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 46172 KB Output is correct
2 Correct 85 ms 47984 KB Output is correct
3 Correct 68 ms 47864 KB Output is correct
4 Correct 134 ms 50680 KB Output is correct
5 Correct 108 ms 51440 KB Output is correct
6 Correct 162 ms 50680 KB Output is correct
7 Correct 74 ms 47960 KB Output is correct
8 Correct 138 ms 50680 KB Output is correct
9 Correct 111 ms 51440 KB Output is correct
10 Correct 130 ms 51556 KB Output is correct
11 Correct 126 ms 49268 KB Output is correct
12 Correct 124 ms 50472 KB Output is correct
13 Correct 127 ms 49528 KB Output is correct
14 Correct 158 ms 50680 KB Output is correct
15 Correct 142 ms 50788 KB Output is correct
16 Correct 50 ms 46072 KB Output is correct
17 Correct 42 ms 46200 KB Output is correct
18 Correct 68 ms 46196 KB Output is correct
19 Correct 41 ms 46172 KB Output is correct
20 Correct 42 ms 46200 KB Output is correct
21 Correct 41 ms 46072 KB Output is correct
22 Correct 42 ms 46248 KB Output is correct
23 Correct 41 ms 46072 KB Output is correct
24 Correct 41 ms 46200 KB Output is correct
25 Correct 41 ms 46116 KB Output is correct