QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226211#7615. Sequence Foldingucup-team1001WA 82ms11180kbC++201.5kb2023-10-25 18:25:542023-10-25 18:25:55

Judging History

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

  • [2023-10-25 18:25:55]
  • 评测
  • 测评结果:WA
  • 用时:82ms
  • 内存:11180kb
  • [2023-10-25 18:25:54]
  • 提交

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) {
        vector<ll> t;
//        print();
        for (auto i = a1.begin(); i != a1.end(); ++i) {
            if (*i > n)break;
            auto r = n + 1 - *i;
            if (a1.find(r) != a1.end())continue;
            if (auto ia2 = a2.find(r);ia2 != a2.end()) {
                t.emplace_back(*ia2);
                a2.erase(ia2);
            } else {
                ans++;
                a2.insert(*i);
                a2.insert(r);
                i = a1.erase(i);
            }
        }
        a1.insert(t.begin(), t.end());
        for (auto i = a2.begin(); i != a2.end(); ++i) {
            if (*i > n)break;
            auto r = n + 1 - *i;
            if (a2.find(r) != a2.end())continue;
            i = a2.erase(i);
        }
        n >>= 1;
    }
//    print();
    cout << ans;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3528kb

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 82ms
memory: 11180kb

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:

66750

result:

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