QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#357698 | #8129. Binary Sequence | squishybanana# | WA | 90ms | 4960kb | C++23 | 1.2kb | 2024-03-19 08:26:54 | 2024-03-19 08:26:55 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int mn = 1e6;
vector<vector<bool>> vals;
void append(vector<bool> &x, int t) {
vector<bool> cur;
while (t) {
cur.push_back(t&1);
t/=2;
}
while (cur.size()) {
x.push_back(cur.back());
cur.pop_back();
}
}
vector<bool> iter(const vector<bool> &val) {
vector<bool> out;
int cnt = 0;
int prev = val[0];
for (int i = 0; i <= val.size(); i++) {
int cur = i < val.size() ? val[i] : -1;
if (prev != cur) {
append(out, cnt);
out.push_back(prev);
prev = cur;
cnt = 1;
}
else {
cnt++;
}
}
return out;
}
void solve() {
ll n, m; cin >> n >> m;
if (n < vals.size()) {
cout << (m < vals[n].size() ? vals[n][vals[n].size()-1-m] : 0) << endl;
}
else {
ll cur = n-vals.size();
if (cur%1 == 0) cur--;
ll x = n-cur-2;
cout << (vals[x][vals[x].size()-1-m]) << endl;
}
}
int main() {
int t; cin >> t;
vector<bool> init;
vals.push_back({});
init = {1};
int cnt = 0;
while (init.size() < mn) {
cnt++;
vals.push_back(init);
init = iter(init);
}
vals.push_back(init);
init = iter(init);
vals.push_back(init);
init = iter(init);
while (t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 82ms
memory: 4928kb
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: 89ms
memory: 4936kb
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: -100
Wrong Answer
time: 90ms
memory: 4960kb
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 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0
result:
wrong answer 65th numbers differ - expected: '1', found: '0'