QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317451#7615. Sequence Foldingnhuang685WA 1ms3572kbC++201.4kb2024-01-29 00:54:222024-01-29 00:54:23

Judging History

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

  • [2024-01-29 00:54:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3572kb
  • [2024-01-29 00:54:22]
  • 提交

answer

/**
 * @file qoj7615-1.cpp
 * @author n685
 * @brief
 * @date 2024-01-28
 *
 *
 */
#include <bits/stdc++.h>

#ifdef LOCAL
#include "dd/debug.h"
#else
#define dbg(...) 42
#define dbgR(...) 4242
#define dbgP(...) 420
#define dbgRP(...) 420420
void nline() {}
#endif

int main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
  std::freopen("output.txt", "w", stdout);
#else
  std::cin.tie(nullptr)->sync_with_stdio(false);
#endif

  int64_t n;
  int m;
  std::cin >> n >> m;

  std::map<int64_t, int> val;
  for (int i = 0; i < m; ++i) {
    int p;
    std::cin >> p;
    --p;
    val[p] = 1;
  }
  int ans = 0;
  while (n > 1) {
    std::map<int64_t, int> cval = val;
    for (auto [aa, bb] : val) {
      int64_t a = aa;
      if (a >= n) {
        continue;
      }
      if (a >= n / 2 && val.contains(n - 1 - a)) {
        continue;
      }
      if (a >= n / 2) {
        a = n - 1 - a;
      }
      int64_t b = n - 1 - a;
      int c, d;
      if (val.contains(a)) {
        c = val[a];
      } else {
        c = 0;
      }
      if (val.contains(d)) {
        d = val[b];
      } else {
        d = 0;
      }
      if ((c == 0 && d == 1) || (c == 1 && d == 0)) {
        ++ans;
        cval[a] = 2;
      } else if (c == 2) {
        cval[a] = d;
      }
    }
    val.swap(cval);
    n /= 2;
  }
  std::cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3572kb

input:

8 3
1 5 8

output:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'