QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#357700 | #8129. Binary Sequence | solar# | AC ✓ | 163ms | 15144kb | C++17 | 1.2kb | 2024-03-19 08:28:10 | 2024-03-19 08:28:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX_LEN = 1e6 + 1000;
string to_bin(ll x) {
string out;
while (x > 0) {
out += (x % 2) + '0';
x /= 2;
}
reverse(out.begin(), out.end());
return out;
}
string gen_next(string x) {
string next_str;
ll idx = 0;
while (idx < x.length()) {
char cur_char = x[idx];
ll len = 0;
while (idx + len < x.length() && x[idx + len] == cur_char) len++;
next_str += to_bin(len) + cur_char;
idx += len;
}
return next_str;
}
signed main() {
ll t;
cin >> t;
string odd = "1", even = "11";
// cout << odd << endl << even << endl;
vector<ll> lengths = {0, 1, 2};
ll cnt = 2;
while (odd.length() < MAX_LEN || even.length() < MAX_LEN) {
odd = gen_next(even);
even = gen_next(odd);
lengths.push_back(odd.length());
lengths.push_back(even.length());
cnt += 2;
// cout << odd << endl << even << endl;
}
reverse(odd.begin(), odd.end());
reverse(even.begin(), even.end());
while (t--) {
ll n, m;
cin >> n >> m;
if (n <= cnt && m >= lengths[n]) {
cout << 0 << endl;
} else if (n & 1) {
cout << odd[m] << endl;
} else {
cout << even[m] << endl;
}
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 64ms
memory: 15144kb
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: 66ms
memory: 14980kb
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: 66ms
memory: 14448kb
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: 163ms
memory: 14188kb
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