답안 #74467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74467 2018-09-02T06:49:05 Z win11905 Paths (BOI18_paths) C++11
100 / 100
519 ms 173612 KB
#include <bits/stdc++.h>
using namespace std;

#define long long long

const int N = 3e5+5;
const int bit = 5;

int n, m, k, col[N];
long d[N][1<<bit];
vector<int> g[N], eb[bit+1];

int main() {
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1; i <= n; ++i) scanf("%d", col+i), col[i]--;
    for(int i = 0, u, v; i < m; ++i) {
        scanf("%d %d", &u, &v);
        g[u].emplace_back(v), g[v].emplace_back(u);
    }
    for(int i = 0; i < (1<<k); ++i) {
        int cnt = 0;
        for(int j = 0; j < k; ++j) if(i >> j & 1) cnt++;
        eb[cnt].emplace_back(i);
    }
    for(int i = 1; i <= n; ++i) d[i][1<<col[i]] = 1;
    long sum = 0;
    for(int i = 2; i <= k; ++i) for(auto x : eb[i]) {
        for(int i = 1; i <= n; ++i) {
            if(x & (1 << col[i])) for(auto v : g[i]) d[i][x] += d[v][x ^ (1<<col[i])]; 
            sum += d[i][x];
        }
    }
    printf("%lld\n", sum);
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:14: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:15:51: 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), col[i]--;
                                 ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
paths.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 9 ms 7416 KB Output is correct
3 Correct 8 ms 7500 KB Output is correct
4 Correct 9 ms 7648 KB Output is correct
5 Correct 8 ms 7648 KB Output is correct
6 Correct 8 ms 7648 KB Output is correct
7 Correct 8 ms 7648 KB Output is correct
8 Correct 8 ms 7648 KB Output is correct
9 Correct 8 ms 7648 KB Output is correct
10 Correct 8 ms 7648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 15408 KB Output is correct
2 Correct 93 ms 16508 KB Output is correct
3 Correct 416 ms 101884 KB Output is correct
4 Correct 159 ms 101884 KB Output is correct
5 Correct 153 ms 101884 KB Output is correct
6 Correct 299 ms 101884 KB Output is correct
7 Correct 373 ms 117212 KB Output is correct
8 Correct 409 ms 122536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 9 ms 7416 KB Output is correct
3 Correct 8 ms 7500 KB Output is correct
4 Correct 9 ms 7648 KB Output is correct
5 Correct 8 ms 7648 KB Output is correct
6 Correct 8 ms 7648 KB Output is correct
7 Correct 8 ms 7648 KB Output is correct
8 Correct 8 ms 7648 KB Output is correct
9 Correct 8 ms 7648 KB Output is correct
10 Correct 8 ms 7648 KB Output is correct
11 Correct 110 ms 15408 KB Output is correct
12 Correct 93 ms 16508 KB Output is correct
13 Correct 416 ms 101884 KB Output is correct
14 Correct 159 ms 101884 KB Output is correct
15 Correct 153 ms 101884 KB Output is correct
16 Correct 299 ms 101884 KB Output is correct
17 Correct 373 ms 117212 KB Output is correct
18 Correct 409 ms 122536 KB Output is correct
19 Correct 108 ms 122536 KB Output is correct
20 Correct 108 ms 122536 KB Output is correct
21 Correct 388 ms 131392 KB Output is correct
22 Correct 149 ms 131392 KB Output is correct
23 Correct 147 ms 131392 KB Output is correct
24 Correct 309 ms 131392 KB Output is correct
25 Correct 382 ms 146568 KB Output is correct
26 Correct 392 ms 151696 KB Output is correct
27 Correct 94 ms 151696 KB Output is correct
28 Correct 127 ms 151696 KB Output is correct
29 Correct 505 ms 160692 KB Output is correct
30 Correct 341 ms 160692 KB Output is correct
31 Correct 316 ms 160692 KB Output is correct
32 Correct 519 ms 173612 KB Output is correct
33 Correct 7 ms 173612 KB Output is correct
34 Correct 7 ms 173612 KB Output is correct
35 Correct 7 ms 173612 KB Output is correct
36 Correct 7 ms 173612 KB Output is correct
37 Correct 8 ms 173612 KB Output is correct
38 Correct 8 ms 173612 KB Output is correct
39 Correct 8 ms 173612 KB Output is correct
40 Correct 8 ms 173612 KB Output is correct
41 Correct 8 ms 173612 KB Output is correct
42 Correct 8 ms 173612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 173612 KB Output is correct
2 Correct 35 ms 173612 KB Output is correct
3 Correct 35 ms 173612 KB Output is correct
4 Correct 116 ms 173612 KB Output is correct
5 Correct 113 ms 173612 KB Output is correct
6 Correct 198 ms 173612 KB Output is correct
7 Correct 35 ms 173612 KB Output is correct
8 Correct 133 ms 173612 KB Output is correct
9 Correct 119 ms 173612 KB Output is correct
10 Correct 129 ms 173612 KB Output is correct
11 Correct 103 ms 173612 KB Output is correct
12 Correct 116 ms 173612 KB Output is correct
13 Correct 107 ms 173612 KB Output is correct
14 Correct 183 ms 173612 KB Output is correct
15 Correct 208 ms 173612 KB Output is correct
16 Correct 9 ms 173612 KB Output is correct
17 Correct 8 ms 173612 KB Output is correct
18 Correct 8 ms 173612 KB Output is correct
19 Correct 8 ms 173612 KB Output is correct
20 Correct 8 ms 173612 KB Output is correct
21 Correct 8 ms 173612 KB Output is correct
22 Correct 9 ms 173612 KB Output is correct
23 Correct 8 ms 173612 KB Output is correct
24 Correct 8 ms 173612 KB Output is correct
25 Correct 8 ms 173612 KB Output is correct