QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#308964#8129. Binary Sequenceucup-team1055#AC ✓94ms39688kbC++202.3kb2024-01-20 14:02:032024-01-20 14:02:05

Judging History

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

  • [2024-01-20 14:02:05]
  • 评测
  • 测评结果:AC
  • 用时:94ms
  • 内存:39688kb
  • [2024-01-20 14:02:03]
  • 提交

answer

#include <bits/stdc++.h>

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T>
bool chmin(T &a, T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

template<class T>
bool chmax(T &a, T b) {
    if(a >= b) return false;
    a = b;
    return true;
}

using namespace std;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    vector<ll> siz(100);
    vector<int> even(0);
    vector<int> odd = {1};
    siz[1] = 1;
    rep(i,2,100){
        vector<int> targ;
        if (i & 1){
            targ = even;
        }else{
            targ = odd;
        }
        int memo = -1;
        int num = 0;
        vector<int> ret;
        auto add = [&]() -> void {
            if (num > 0){
                vector<int> a;
                while(num > 0){
                    a.push_back(num % 2);
                    num /= 2;
                }
                reverse(all(a));
                for (int j: a) ret.push_back(j);
                ret.push_back(memo);
            }
        };
        rep(j,0,(int)targ.size()){
            if (memo != targ[j]){
                add();    
                memo = targ[j];
                num = 1;  
            }else{
                num++;
            }
        }
        if (num > 0) add();
        if (i & 1){
            odd = ret;
            siz[i] = odd.size();
        }else{
            even = ret;
            siz[i] = even.size();
        }
        if (odd.size() > 1111111 && even.size() > 1111111){
            reverse(all(odd));
            reverse(all(even));
            odd.resize(1100000);
            even.resize(1100000);
            siz.resize(i + 1);
            break;   
        }
    }

    int t; cin >> t;
    while(t--){
        ll n; int m; cin >> n >> m;
        if (n < (ll)siz.size() && siz[n] <= m){
            cout << 0 << '\n';
        }else{
            if (n & 1){
                cout << odd[m] << '\n';
            }else{
                cout << even[m] << '\n';
            }
        }
    }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 77ms
memory: 38888kb

input:

10
4 0
4 1
4 2
4 3
4 4
4 5
4 6
6 3
6 7
118999881999119725 3

output:

1
1
0
1
1
1
0
1
1
0

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 70ms
memory: 38716kb

input:

10
28 69772
10 7908
4 3198
4 85913
14 52729
3 20445
9 88912
17 23743
25 37356
2 97697

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 80ms
memory: 38976kb

input:

100
29 110358
18 13645
18 590344
36 550462
11 133055
8 769352
11 265432
7 158530
12 29189
2 830361
11 584395
31 693707
7 879812
19 25069
21 616926
3 85158
31 675739
17 118385
24 315535
29 59615
10 33445
17 609235
8 738138
20 209540
4 287616
32 522302
26 959741
5 453537
27 74313
28 296289
28 857972
2...

output:

0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 94ms
memory: 39688kb

input:

100000
702433635413308636 962533
864089450531108488 538792
262747333715821506 454514
859830947243984718 105219
365621373252206174 447331
890829905503831899 507146
116987306031929573 154370
157986473366693144 364746
502917586764426513 49981
874588963478161584 594867
467219058104100510 790503
11034861...

output:

1
1
1
1
1
1
1
0
1
0
1
0
1
1
1
1
0
1
1
1
1
1
0
1
0
0
0
0
1
1
1
0
0
1
1
0
0
1
0
1
1
1
1
0
0
0
0
1
1
0
0
1
0
0
1
0
1
1
1
1
1
1
1
0
1
1
1
0
0
0
1
1
1
0
1
1
1
1
1
1
0
1
0
1
1
1
0
0
0
1
0
0
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
0
1
1
0
1
1
0
1
0
0
0
1
1
0
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
1
1
1
0
0
1
...

result:

ok 100000 numbers

Extra Test:

score: 0
Extra Test Passed