QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226226#7618. Pattern Searchucup-team1001WA 0ms3716kbC++201.6kb2023-10-25 18:38:142023-10-25 18:38:15

Judging History

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

  • [2023-10-25 18:38:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3716kb
  • [2023-10-25 18:38:14]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);


using ll = long long;
#define endl "\n"

ll n, m;
set<ll> a1, a2;

void print() {
    for (int i = 1; i <= n; ++i) {
        if (a1.find(i) != a1.end())cout << 1;
        else if (a2.find(i) != a2.end())cout << 2;
        else cout << 0;
    }
    cout << endl;
    for (auto &&i: a1) {
        cout << i << " ";
    }
    cout << endl;
    for (auto &&i: a2) {
        cout << i << " ";
    }
    cout << endl;
}


int main() {
    cin >> n >> m;
    for (ll i = 0; i < m; ++i) {
        ll x;
        cin >> x;
        a1.insert(x);
    }
    ll ans = 0;
    while (n != 1) {
//        print();
        for (auto i = a1.begin(); i != a1.end();) {
            if (*i > n)break;
            auto r = n + 1 - *i;
            if (a1.find(r) != a1.end()) {
                ++i;
                continue;
            }
            if (a2.find(r) != a2.end()) {
                ++i;
                continue;
            }
            ans++;
            a2.insert(*i);
            a2.insert(r);
            i = a1.erase(i);
        }
        for (auto i = a2.begin(); i != a2.end();) {
            if (*i > n)break;
            auto r = n + 1 - *i;
            if (a2.find(r) != a2.end()) {
                ++i;
                continue;
            }
            if (a1.find(r) != a1.end()) {
                a1.insert(*i);
                i = a2.erase(i);
            } else {
                i = a2.erase(i);
            }
        }
        n >>= 1;
    }
//    print();
    cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3716kb

input:

2
bajkaaall aal
abca cba

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'