QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#376079 | #8129. Binary Sequence | pandapythoner# | AC ✓ | 60ms | 10688kb | C++17 | 1.6kb | 2024-04-03 20:27:55 | 2024-04-03 20:27:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define mp make_pair
using pi = pair<int, int>;
using str = string;
const ll inf = 1e18;
mt19937 rnd(234);
const int maxM = 1e6, SZ = 38;
map<pi, int> dict;
str s[SZ];
str to_binary(int x) {
str s;
int id = -1;
for (int i = 31; i >= 0; i--) {
if (x & (1 << i)) {
id = i;
break;
}
}
for (int i = id; i >= 0; i--) {
if (x & (1 << i)) {
s += '1';
} else {
s += '0';
}
}
reverse(s.begin(), s.end());
return s;
}
void precalc() {
s[0] = "1";
for (int i = 1; i < SZ; i++) {
for (int l = 0, r = 0; l < s[i - 1].size() && s[i].size() < maxM; l = r) {
while (r < s[i - 1].size() && s[i - 1][l] == s[i - 1][r]) {
r++;
}
s[i] += s[i - 1][l];
s[i] += to_binary(r - l);
}
}
}
void solve() {
ll n;
int m;
cin >> n >> m;
n--;
if (n < SZ) {
if (m >= s[n].size()) {
cout << "0\n";
} else {
cout << s[n][m] << "\n";
}
return;
}
cout << s[n % 2 + 36][m] << "\n";
}
int32_t main() {
if (1) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
precalc();
int test = 1;
cin >> test;
while (test--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 35ms
memory: 10604kb
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: 35ms
memory: 10688kb
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: 43ms
memory: 10568kb
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: 10616kb
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