QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317971#7615. Sequence Foldingnhuang685WA 784ms17640kbC++201.6kb2024-01-30 06:36:562024-01-30 06:36:57

Judging History

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

  • [2024-01-30 06:36:57]
  • 评测
  • 测评结果:WA
  • 用时:784ms
  • 内存:17640kb
  • [2024-01-30 06:36:56]
  • 提交

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;
    std::vector<std::pair<int64_t, int>> vv(val.begin(), val.end());
    for (auto [aa, bb] : vv) {
      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 {
        val[a] = 0;
        c = 0;
      }
      if (val.contains(b)) {
        d = val[b];
      } else {
        val[b] = 0;
        d = 0;
      }
      if ((c == 0 && d == 1) || (c == 1 && d == 0)) {
        ++ans;
        val[a] = 2;
      } else if (c == 2) {
        val[a] = d;
      }
    }
    // val.swap(cval);
    n /= 2;
    while (!val.empty() && val.rbegin()->first >= n) {
      val.erase(std::prev(val.end()));
    }
  }
  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: 3876kb

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 784ms
memory: 17640kb

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'