Submission #283414

# Submission time Handle Problem Language Result Execution time Memory
283414 2020-08-25T16:54:42 Z AlexLuchianov Paths (BOI18_paths) C++14
53 / 100
365 ms 33008 KB
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
int const sigma = 5;
int v[1 + nmax];
ll dp[1 + nmax][1 << sigma];
std::vector<int> g[1 + nmax];

int main() {
  int n, m, k;
  std::cin >> n >> m >> k;
  for(int i = 1;i <= n; i++) {
    std::cin >> v[i];
    v[i]--;
  }
  
  for(int i = 1;i <= m; i++) {
    int x, y;
    std::cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  ll result = 0;
  for(int mask = 1; mask < (1 << sigma); mask++) {
    for(int i = 1; i <= n; i++) {
      if(0 < ((1 << v[i]) & mask)) {
        if(0 < ((1 << v[i]) ^ mask)) {
          for(int h = 0; h < g[i].size(); h++) {
            int to = g[i][h];
            dp[i][mask] += dp[to][mask ^ (1 << v[i])];
          }
        } else
          dp[i][mask] = 1;
      }
      result += dp[i][mask];
    }
  }
  std::cout << result - n;
  return 0;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:35:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |           for(int h = 0; h < g[i].size(); h++) {
      |                          ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2816 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 331 ms 10392 KB Output is correct
2 Correct 279 ms 8696 KB Output is correct
3 Runtime error 40 ms 6268 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2816 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 331 ms 10392 KB Output is correct
12 Correct 279 ms 8696 KB Output is correct
13 Runtime error 40 ms 6268 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 88 ms 4600 KB Output is correct
3 Correct 92 ms 4728 KB Output is correct
4 Correct 365 ms 32248 KB Output is correct
5 Correct 240 ms 33008 KB Output is correct
6 Correct 328 ms 32248 KB Output is correct
7 Correct 89 ms 4728 KB Output is correct
8 Correct 334 ms 32376 KB Output is correct
9 Correct 267 ms 33004 KB Output is correct
10 Correct 288 ms 33004 KB Output is correct
11 Correct 204 ms 18420 KB Output is correct
12 Correct 217 ms 25840 KB Output is correct
13 Correct 201 ms 18544 KB Output is correct
14 Correct 319 ms 32328 KB Output is correct
15 Correct 313 ms 32376 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2720 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 2 ms 2688 KB Output is correct