QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310044#8129. Binary Sequenceucup-team1134#AC ✓169ms69996kbC++231.7kb2024-01-21 00:20:072024-01-21 00:20:08

Judging History

你现在查看的是最新测评结果

  • [2024-01-21 00:20:08]
  • 评测
  • 测评结果:AC
  • 用时:169ms
  • 内存:69996kb
  • [2024-01-21 00:20:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=1100005,INF=1<<30;

string ans[MAX];
ll len[43];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S="1";
    for(int t=1;t<=40;t++){
        //cout<<t<<" "<<si(S)<<endl;
        len[t]=si(S);
        for(int i=0;i<min(1000005,si(S));i++){
            ans[i]+=S[si(S)-1-i];
        }
        string T;
        int i=0;
        while(i<si(S)){
            int j=i;
            while(j<si(S)&&S[i]==S[j]) j++;
            int cn=j-i;
            for(int k=30;k>=0;k--){
                if(cn&(1<<k)){
                    for(int x=k;x>=0;x--){
                        if(cn&(1<<x)) T+='1';
                        else T+='0';
                    }
                    break;
                }
            }
            T+=S[i];
            
            i=j;
        }
        S=T;
    }
    
    for(int i=0;i<MAX;i++) reverse(all(ans[i]));
    
    int Q;cin>>Q;
    while(Q--){
        ll N,M;cin>>N>>M;
        if(N<=40){
            if(len[N]<=M) cout<<"0\n";
            else cout<<ans[M][40-N]<<"\n";
        }else{
            if(ans[M][0]==ans[M][1]) cout<<ans[M][0]<<"\n";
            else cout<<ans[M][N&1]<<"\n";
        }
    }
    
}


这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 136ms
memory: 69996kb

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: 142ms
memory: 67816kb

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: 160ms
memory: 68828kb

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: 169ms
memory: 69904kb

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