QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#473083 | #8129. Binary Sequence | ucup-team1198# | AC ✓ | 31ms | 33352kb | C++20 | 1.7kb | 2024-07-11 21:45:07 | 2024-07-11 21:45:08 |
Judging History
answer
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
const int MAXN = 1'000'100;
vector<vector<int>> lines;
lines.emplace_back(1, 1);
while (true) {
vector<int> cur;
int cnt = 0;
int val = lines.back().front();
auto add_num = [&](int cnt) {
assert(1 <= cnt && cnt <= 4);
cur.emplace_back(1);
if (cnt == 1) {
;
} else if (cnt == 3) {
cur.emplace_back(1);
} else {
cur.emplace_back(0);
if (cnt == 4)
cur.emplace_back(0);
}
};
for (int x : lines.back()) {
if (x == val) {
++cnt;
} else {
add_num(cnt);
cur.emplace_back(val);
cnt = 1;
val = x;
}
}
add_num(cnt);
cur.emplace_back(val);
lines.emplace_back(cur);
if (lines[lines.size() - 2].size() >= MAXN)
break;
}
int t;
cin >> t;
while (t--) {
long long n;
int m;
cin >> n >> m;
if (n <= lines.size()) {
--n;
if (m >= lines[n].size()) {
cout << 0 << '\n';
} else {
cout << lines[n][lines[n].size() - 1 - m] << '\n';
}
} else {
int real_id = lines.size() - 1;
--n;
if (n % 2 != real_id % 2)
--real_id;
cout << lines[real_id][lines[real_id].size() - 1 - m] << '\n';
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 33268kb
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: 0ms
memory: 33268kb
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: 13ms
memory: 33352kb
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: 31ms
memory: 33264kb
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