QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317964#7615. Sequence Foldingnhuang685WA 224ms16144kbC++201.4kb2024-01-30 05:38:582024-01-30 05:38:58

Judging History

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

  • [2024-01-30 05:38:58]
  • 评测
  • 测评结果:WA
  • 用时:224ms
  • 内存:16144kb
  • [2024-01-30 05:38:58]
  • 提交

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) {
        break;
      }
      if (a >= n / 2) {
        if (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(b)) {
        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 = cval;
    // val.swap(cval);
    n /= 2;
  }
  std::cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 224ms
memory: 16144kb

input:

17179869184 100000
138476 774165 993977 1152277 1236393 1244970 1534017 1693701 1763926 1778781 1842066 1874644 1885666 2120429 2485344 2977941 3158255 3340476 3504862 4000117 4066652 4197639 4338723 4389163 4576965 4761601 5097091 5175412 5295902 5810551 5855982 6001770 6111262 6163309 6351547 6582...

output:

99998

result:

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