답안 #121013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121013 2019-06-26T02:20:10 Z IOrtroiii Paths (BOI18_paths) C++14
100 / 100
1215 ms 97400 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
const int N = 300300;
const int K = 5;

int n, m, k;
int a[N];
vector<int> g[N];
ll f[N][1 << K];

int main() {
   scanf("%d %d %d", &n, &m, &k);
   for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
      --a[i];
   }
   for (int i = 1; i <= m; ++i) {
      int u, v;
      scanf("%d %d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
   }
   for (int i = 1; i <= n; ++i) {
      f[i][1 << a[i]] = 1ll;
   }
   ll ans = 0;
   for (int mask = 1; mask < (1 << k); ++mask) {
      for (int i = 1; i <= n; ++i) {
         ans += f[i][mask];
         for (int j : g[i]) {
            if (mask & (1 << a[j])) {
               continue;
            }
            f[j][mask | (1 << a[j])] += f[i][mask];
         }
      }
   }
   printf("%lld\n", ans - n);
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:15:9: 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:17:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", a + i);
       ~~~~~^~~~~~~~~~~~~
paths.cpp:22:12: 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 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 7 ms 7424 KB Output is correct
4 Correct 8 ms 7424 KB Output is correct
5 Correct 7 ms 7396 KB Output is correct
6 Correct 7 ms 7424 KB Output is correct
7 Correct 7 ms 7424 KB Output is correct
8 Correct 7 ms 7424 KB Output is correct
9 Correct 8 ms 7424 KB Output is correct
10 Correct 7 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 12428 KB Output is correct
2 Correct 88 ms 11128 KB Output is correct
3 Correct 640 ms 96248 KB Output is correct
4 Correct 162 ms 22876 KB Output is correct
5 Correct 142 ms 22768 KB Output is correct
6 Correct 389 ms 69616 KB Output is correct
7 Correct 734 ms 96668 KB Output is correct
8 Correct 663 ms 97264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 7 ms 7424 KB Output is correct
4 Correct 8 ms 7424 KB Output is correct
5 Correct 7 ms 7396 KB Output is correct
6 Correct 7 ms 7424 KB Output is correct
7 Correct 7 ms 7424 KB Output is correct
8 Correct 7 ms 7424 KB Output is correct
9 Correct 8 ms 7424 KB Output is correct
10 Correct 7 ms 7424 KB Output is correct
11 Correct 117 ms 12428 KB Output is correct
12 Correct 88 ms 11128 KB Output is correct
13 Correct 640 ms 96248 KB Output is correct
14 Correct 162 ms 22876 KB Output is correct
15 Correct 142 ms 22768 KB Output is correct
16 Correct 389 ms 69616 KB Output is correct
17 Correct 734 ms 96668 KB Output is correct
18 Correct 663 ms 97264 KB Output is correct
19 Correct 111 ms 15156 KB Output is correct
20 Correct 88 ms 13504 KB Output is correct
21 Correct 608 ms 96548 KB Output is correct
22 Correct 156 ms 22904 KB Output is correct
23 Correct 139 ms 22908 KB Output is correct
24 Correct 387 ms 69584 KB Output is correct
25 Correct 630 ms 96720 KB Output is correct
26 Correct 658 ms 97400 KB Output is correct
27 Correct 115 ms 13304 KB Output is correct
28 Correct 186 ms 16632 KB Output is correct
29 Correct 1215 ms 96640 KB Output is correct
30 Correct 591 ms 55400 KB Output is correct
31 Correct 565 ms 55532 KB Output is correct
32 Correct 1069 ms 96632 KB Output is correct
33 Correct 7 ms 7424 KB Output is correct
34 Correct 8 ms 7424 KB Output is correct
35 Correct 7 ms 7424 KB Output is correct
36 Correct 8 ms 7424 KB Output is correct
37 Correct 8 ms 7424 KB Output is correct
38 Correct 8 ms 7424 KB Output is correct
39 Correct 8 ms 7424 KB Output is correct
40 Correct 8 ms 7424 KB Output is correct
41 Correct 7 ms 7424 KB Output is correct
42 Correct 7 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 7424 KB Output is correct
2 Correct 58 ms 8568 KB Output is correct
3 Correct 33 ms 8568 KB Output is correct
4 Correct 133 ms 35648 KB Output is correct
5 Correct 104 ms 36336 KB Output is correct
6 Correct 328 ms 35704 KB Output is correct
7 Correct 41 ms 8696 KB Output is correct
8 Correct 176 ms 35576 KB Output is correct
9 Correct 146 ms 36336 KB Output is correct
10 Correct 178 ms 36208 KB Output is correct
11 Correct 162 ms 22104 KB Output is correct
12 Correct 170 ms 29268 KB Output is correct
13 Correct 139 ms 22032 KB Output is correct
14 Correct 301 ms 35576 KB Output is correct
15 Correct 363 ms 35832 KB Output is correct
16 Correct 8 ms 7424 KB Output is correct
17 Correct 8 ms 7424 KB Output is correct
18 Correct 9 ms 7464 KB Output is correct
19 Correct 8 ms 7424 KB Output is correct
20 Correct 8 ms 7424 KB Output is correct
21 Correct 8 ms 7424 KB Output is correct
22 Correct 8 ms 7424 KB Output is correct
23 Correct 8 ms 7424 KB Output is correct
24 Correct 7 ms 7424 KB Output is correct
25 Correct 7 ms 7396 KB Output is correct