QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#278844#7615. Sequence Foldingucup-team859WA 3402ms54728kbC++171.3kb2023-12-07 21:19:552023-12-07 21:19:55

Judging History

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

  • [2023-12-07 21:19:55]
  • 评测
  • 测评结果:WA
  • 用时:3402ms
  • 内存:54728kb
  • [2023-12-07 21:19:55]
  • 提交

answer

#include <bits/stdc++.h>

#define lsb(x) (x & (-x))

using ull = unsigned long long;
using ll = long long;

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("input.in");
    ofstream cout("output.out");
#endif
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    ll n;
    int m;
    cin >> n >> m;

    unordered_map<ll, int> values;
    for (int i = 0; i < m; i++) {
        ll pos;
        cin >> pos;
        values[pos] = 1;
    }
    
    int answer = 0;
    for (ll len = n / 2; len >= 1; len /= 2) {
        set<pair<ll, ll>> vis;
        for (auto [pos, v] : values) {
            if (pos > 2 * len) continue;

            ll a, b;
            if (pos <= len) {
                a = pos;
                b = 2 * len - pos + 1;
            } else {
                a = 2 * len - pos + 1;
                b = pos;
            }

            if (vis.find({a, b}) != vis.end()) continue;
            vis.insert({a, b});

            if (values[a] == values[b]) {
                continue;
            }

            if (values[a] == 2 || values[b] == 2) {
                values[a] = values[b] = min(values[a], values[b]);
                continue;
            }

            answer++;
            values[a] = values[b] = 2;
        }
    }

    cout << answer;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 3402ms
memory: 54728kb

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:

85078

result:

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