QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224933#7615. Sequence FoldingSolitaryDream#WA 51ms9688kbC++171.3kb2023-10-23 17:59:452023-10-23 17:59:45

Judging History

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

  • [2023-10-23 17:59:45]
  • 评测
  • 测评结果:WA
  • 用时:51ms
  • 内存:9688kb
  • [2023-10-23 17:59:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, pii> mp;
    for (int i = 1, x; i <= m; ++i) {
        cin >> x;
        mp[x] = pii(1, 0);
    }
    int ans = 0;
    while (n > 1) {
        int lim = n / 2;
        for (auto [x, _] : mp) {
            if (x > lim) break;
            if (!mp.count(n + 1 - lim)) mp[n + 1 - lim] = pii(0, 0);
        }
        while (!mp.empty() && prev(mp.end())->first > lim) {
            auto [pos, tmp] = *prev(mp.end());
            auto [val, is_sp] = tmp;
            mp.erase(--mp.end());
            if (is_sp) continue;
            int npos = n + 1 - pos;
            if (!mp.count(npos)) {
                ans += 1;
                mp[npos] = pii(0, 1); // not sure
                continue;
            }
            auto &[nval, nis_sp] = mp[npos];
            if (nis_sp) {
                nis_sp = 0;
                nval = val;
            } else if (nval == val) {
                // pass
            } else {
                ans += 1;
                nis_sp = 1;
            }
        }
        n = lim;
    }
    cout << ans << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 51ms
memory: 9688kb

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:

100023

result:

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