QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318883#7615. Sequence Foldingnhuang685WA 707ms17592kbC++201.7kb2024-02-01 05:28:282024-02-01 05:28:29

Judging History

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

  • [2024-02-01 05:28:29]
  • 评测
  • 测评结果:WA
  • 用时:707ms
  • 内存:17592kb
  • [2024-02-01 05:28:28]
  • 提交

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) {
    dbg(n, (int)val.size());
    // std::map<int64_t, int> cval = val;
    std::vector<std::pair<int64_t, int>> vv(val.begin(), val.end());
    for (auto [aa, bb] : vv) {
      if (!val.contains(n - 1 - aa)) {
        val[n - 1 - aa] = 0;
      }
    }
    for (auto [aa, bb] : val) {
      int64_t a = aa;
      if (a >= n / 2) {
        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;
      assert(a < b);
      assert(b >= n / 2);
      int c, d;
      c = val[a];
      d = val[b];
      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';
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3552kb

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 707ms
memory: 17592kb

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'