QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323964#8129. Binary Sequenceucup-team055#AC ✓371ms29040kbC++231.2kb2024-02-10 14:41:232024-02-10 14:41:25

Judging History

This is the latest submission verdict.

  • [2024-02-10 14:41:25]
  • Judged
  • Verdict: AC
  • Time: 371ms
  • Memory: 29040kb
  • [2024-02-10 14:41:23]
  • Submitted

answer

#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

const int L = 1234567;

string binary(int n) {
    string binStr = "";
    while (n > 0) {
        binStr = char((n % 2) + '0') + binStr;
        n /= 2;
    }
    return binStr;
}

string say(string A) {
    char c = '1';
    int cnt = 0;
    int mx_cnt = 0;
    string ans = "";
    for (char a : A) {
        if (a != c) {
            ans += binary(cnt) + c;
            c = a;
            cnt = 0;
        }
        cnt++;
    }
    ans += binary(cnt) + c;
    if (ans.length() > L) {
        ans = ans.substr(ans.length() - L);
    }
    return ans;
}

int main() {
    vector<string> s;
    s.push_back("1");
    for (int i = 0; i < 50; ++i) {
        s.push_back(say(s.back()));
    }

    int t;
    cin >> t;
    while(t--) cout << [&]() -> char {
        ll N, M;
        cin >> N >> M;
        N--;
        if (N > 50) {
            N -= (N - 48) / 2 * 2;
        }
        if (M >= s[N].length()) {
            return '0';
        } else {
            return s[N].rbegin()[M];
        }
    }() << '\n';
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 266ms
memory: 29040kb

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: 267ms
memory: 28880kb

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: 259ms
memory: 28996kb

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: 371ms
memory: 28952kb

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