QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#309130#8129. Binary Sequenceucup-team1516#AC ✓60ms14584kbC++171.4kb2024-01-20 15:00:552024-01-20 15:00:57

Judging History

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

  • [2024-01-20 15:00:57]
  • 评测
  • 测评结果:AC
  • 用时:60ms
  • 内存:14584kb
  • [2024-01-20 15:00:55]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    auto binary = [&](int n) -> string {
        string res;
        while (n) {
            res += (char)('0' + n%2);
            n /= 2;
        }
        reverse(res.begin(), res.end());
        return res;
    };
    vector<string> str(38);
    str[0] = "1";
    for (int i = 1; i < 38; ++i) {
        for (int j = 0; j < str[i-1].size();) {
            int cnt = 0;
            char c = str[i-1][j];
            while (j < str[i-1].size() and str[i-1][j] == c) {
                cnt += 1; j += 1;
            }
            str[i] += binary(cnt);
            str[i] += c;
        }
    }
    int q; cin >> q;
    while (q--) {
        ll n,m; cin >> n >> m;
        if (n > 38) {
            if (n%2) n = 37;
            else n = 38;
        }
        n--; m += 1;
        if (str[n].size() < m) {
            cout << 0 << "\n";
        }
        else {
            cout << str[n][str[n].size()-m] << "\n";
        }
    }
}

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

详细

Test #1:

score: 100
Accepted
time: 42ms
memory: 14584kb

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: 41ms
memory: 14272kb

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: 42ms
memory: 14352kb

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: 60ms
memory: 13884kb

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