QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#422473#7303. City UniteddayuxWA 20ms168896kbC++141.5kb2024-05-27 14:52:072024-05-27 14:52:08

Judging History

你现在查看的是最新测评结果

  • [2024-05-27 14:52:08]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:168896kb
  • [2024-05-27 14:52:07]
  • 提交

answer

#include <bits/stdc++.h>

const int maxn = 50, maxd = 13, mod = 4;

std::array<int, maxn + 1> e;
std::array<std::array<std::array<short, 1 << maxd>, 1 << maxd>, 2> f;

void inc(short &x, short y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);

  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    std::cin >> u >> v;
    e[std::max(u, v)] |= 1 << (std::abs(u - v) - 1);
  }

  f[0 & 1][0][0] = 1;
  int all = (1 << maxd) - 1;
  for (int i = 1; i <= n; ++i) {
    for (int S = 0; S <= all; ++S) {
      for (int T = S; ; T = (T - 1) & S) {
        f[i & 1][S][T] = 0;
        if (T == 0) {
          break;
        }
      }
    }
    for (int S = 0; S <= all; ++S) {
      for (int T = S; ; T = (T - 1) & S) {
        if (f[(i - 1) & 1][S][T] != 0) {
          inc(f[i & 1][(S << 1) & all][(T << 1) & all], f[(i - 1) & 1][S][T]);
          if ((e[i] & (S ^ T)) == 0) {
            inc(f[i & 1][(S << 1 | 1) & all][(T << 1) & all], f[(i - 1) & 1][S][T]);
          }
          if ((e[i] & T) == 0) {
            inc(f[i & 1][(S << 1 | 1) & all][(T << 1 | 1) & all], f[(i - 1) & 1][S][T]);
          }
        }
        if (T == 0) {
          break;
        }
      }
    }
  }

  short ans = 0;
  for (int S = 0; S <= all; ++S) {
    for (int T = S; ; T = (T - 1) & S) {
      inc(ans, f[n & 1][S][T]);
      if (T == 0) {
        break;
      }
    }
  }
  std::cout << ans / 2 << "\n";
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 20ms
memory: 168896kb

input:

3 2
1 2
2 3

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: -100
Wrong Answer
time: 20ms
memory: 166760kb

input:

3 3
1 2
2 3
3 1

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'