QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584598 | #8129. Binary Sequence | ucup-team3519# | AC ✓ | 63ms | 56096kb | C++20 | 1.6kb | 2024-09-23 15:40:53 | 2024-09-23 15:40:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
#define all0(x) (x).begin(), (x).end()
typedef long long LL;
void solve() {
// LL n, m; cin >> n >> m;
V<V<int>> bef(1);
V<int> a(1, 1);
V<int> pa;
auto gen = [&](V<int>&a, int x) -> void {
for(int i = __lg(x); i >= 0; i--) {
a.pb(x >> i & 1);
}
};
V<int> odd, even;
int n = 1;
int t = 40;
bef.pb(a);
while(t) {
t--;
pa = a;
a.clear();
for(int i = 0; i < pa.size(); i++) {
int r = i;
while(r < pa.size() && pa[r] == pa[i]) {
r++;
}
r--;
gen(a, r - i + 1);
a.pb(pa[i]);
i = r;
}
n++;
reverse(all0(a));
a.resize(min((int)a.size(), (int)1e6));
reverse(all0(a));
bef.pb(a);
if(a.size() == 1e6) {
if(n & 1) {
odd = a;
} else {
even = a;
}
}
}
cin >> t;
while(t--) {
LL n, m; cin >> n >> m;
m++;
if(n <= 40) {
if(m > bef[n].size()) cout << 0 << endl;
else cout << bef[n][bef[n].size() - m] << endl;
} else {
if(n & 1) cout << odd[odd.size() - m] << endl;
else cout << even[even.size() - m] << endl;
}
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
// int t;
// std::cin >> t;
// while (t--) {
// solve();
// }
solve();
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 37ms
memory: 56096kb
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: 43ms
memory: 54956kb
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: 39ms
memory: 55276kb
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: 63ms
memory: 55760kb
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