QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313794#8129. Binary Sequenceucup-team093#AC ✓57ms13652kbC++201.0kb2024-01-24 23:47:522024-01-24 23:47:52

Judging History

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

  • [2024-01-24 23:47:52]
  • 评测
  • 测评结果:AC
  • 用时:57ms
  • 内存:13652kb
  • [2024-01-24 23:47:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

string toBS(int x) {
    string ret;
    while(x > 0) {
        ret.push_back('0' + x % 2);
        x /= 2;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

string evolve(const string &s) {
    string ret;
    for(int i = 0, cnt = 0; i < s.size(); i ++) {
        cnt ++;
        if(i + 1 >= s.size() || s[i] != s[i + 1]) {
            ret += toBS(cnt);
            ret.push_back(s[i]);
            cnt = 0;
        }
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<string> t;
    t.push_back("1");
    while(t.back().size() < 2000000) t.push_back(evolve(t.back()));

    int T;
    cin >> T;
    while(T --) {
        i64 n, m;
        cin >> n >> m;
        if(n > t.size()) {
            n -= ((n - t.size() + 1) | 1) ^ 1;
        }
        n --;
        if(t[n].size() <= m) cout << "0\n";
        else cout << t[n][t[n].size() - 1 - m] << "\n";
    }
}

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

详细

Test #1:

score: 100
Accepted
time: 40ms
memory: 13276kb

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: 37ms
memory: 13068kb

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: 36ms
memory: 13416kb

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: 57ms
memory: 13652kb

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