QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310009 | #8129. Binary Sequence | ucup-team197# | AC ✓ | 40ms | 11148kb | C++20 | 1.7kb | 2024-01-20 23:52:47 | 2024-01-20 23:52:47 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <array>
using namespace std;
typedef long long ll;
vector<string> s;
string nxt(string prv){
int cnt = 0;
string result = "";
for(int i = 0; i < prv.size(); ++i){
++cnt;
if(i == (int)prv.size() - 1 || prv[i] != prv[i + 1]){
string to_add = "";
while(cnt > 0){
to_add += '0' + (cnt % 2);
cnt /= 2;
}
while(!to_add.empty()){
result += to_add.back();
to_add.pop_back();
}
result += prv[i];
cnt = 0;
continue;
}
}
return result;
}
void init(){
s.push_back("1");
s.push_back("11");
while(s[s.size() - 2].size() < (int)1e6){
s.push_back(nxt(s.back()));
// cout << s.back().size() << endl;
// if(s.back().size() < 100){
// cout << s.back() << endl;
// }
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
init();
int t;
cin >> t;
while(t--){
ll n, m;
cin >> n >> m;
--n;
++m;
if(n < s.size()){
if(m > s[n].size()){
cout << "0\n";
continue;
}
cout << s[n][(int)s[n].size() - m] << "\n";
continue;
}
n &= 1;
if((n & 1) == ((s.size() - 1) & 1)){
n = s.size() - 1;
}
else{
n = s.size() - 2;
}
cout << s[n][(int)s[n].size() - m] << "\n";
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 17ms
memory: 11044kb
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: 16ms
memory: 11148kb
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: 16ms
memory: 10912kb
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: 40ms
memory: 10976kb
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