QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581074 | #8129. Binary Sequence | ucup-team1766# | WA | 47ms | 19316kb | C++17 | 1.4kb | 2024-09-22 06:40:42 | 2024-09-22 06:40:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MAXS = 39;
string strs[MAXS];
string get_next(string& str){
string temp;
int am = 0;
char prev = '1';
for(int i = 0; i < str.size(); i++){
if(str[i] == prev){
am++;
}else{
string temp2;
while(am > 0){
if(am & 1){
temp2.push_back('1');
}else{
temp2.push_back('0');
}
am /= 2;
}
reverse(temp2.begin(), temp2.end());
temp += temp2;
temp += prev;
am = 1;
}
prev = str[i];
}
string temp2;
while(am > 0){
if(am & 1){
temp2.push_back('1');
}else{
temp2.push_back('0');
}
am /= 2;
}
reverse(temp2.begin(), temp2.end());
temp += temp2;
temp += prev;
return temp;
}
void solve() {
long long n;
int m;
cin >> n >> m;
n--;
if (n < MAXS && m >= strs[n].length()) {
return;
}
if (n % 2 == 0) {
int len = strs[MAXS - 1].length();
cout << strs[MAXS - 1][len - m - 1] << "\n";
} else {
int len = strs[MAXS - 2].length();
cout << strs[MAXS - 2][len - m - 1] << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
strs[0] = "1";
for (int i = 1; i < MAXS; i++) {
strs[i] = get_next(strs[i - 1]);
}
for (int i = 0; i < 5; i++) {
cout << strs[i] << "\n";
}
int t;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 47ms
memory: 19316kb
input:
10 4 0 4 1 4 2 4 3 4 4 4 5 4 6 6 3 6 7 118999881999119725 3
output:
1 11 101 111011 11110101 1 1 0 1 1 1 1 1 0
result:
wrong answer 2nd numbers differ - expected: '1', found: '11'