QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309633#8129. Binary Sequenceucup-team1303#AC ✓89ms43068kbC++142.1kb2024-01-20 19:22:432024-01-20 19:22:44

Judging History

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

  • [2024-01-20 19:22:44]
  • 评测
  • 测评结果:AC
  • 用时:89ms
  • 内存:43068kb
  • [2024-01-20 19:22:43]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define mk make_pair
#define fi first
#define se second

using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
	for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
	return x*f;
}

const int mod=998244353;
int ksm(int x,int y,int p=mod){
	int ans=1;
	for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
	return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}

void cmax(int &x,int v){x=max(x,v);}
void cmin(int &x,int v){x=min(x,v);}

signed main(void){

#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
#endif

	auto getv=[&](int x){
		vector<int>res;
		while(x)res.emplace_back(x&1),x>>=1;
		reverse(res.begin(),res.end());
		return res;
	};
	auto get=[&](vector<int>a){
		vector<int>res;int n=a.size(),cnt=1;
		for(int i=1;i<n;i++){
			if(a[i]!=a[i-1]){
				auto A=getv(cnt);
				for(int t:A)res.emplace_back(t);
				res.emplace_back(a[i-1]);
				cnt=0;
			}
			cnt++;
		}
		auto A=getv(cnt);
		for(int t:A)res.emplace_back(t);
		res.emplace_back(a[n-1]);
		return res;
	};

	vector<vector<int> >A;
	vector<int>cur(1,1);
	A.emplace_back(vector<int>());
	A.emplace_back(cur),cur=get(cur);
	const int LIM=1e6;
	while(cur.size()<=LIM){
		// cout<<"cur = ";cout<<cur.size()<<endl;
		A.emplace_back(cur);
		cur=get(cur);
	}
	// cout<<"cur = ";cout<<cur.size()<<endl;
	A.emplace_back(cur),cur=get(cur);
	// cout<<"cur = ";cout<<cur.size()<<endl;
	A.emplace_back(cur);

	int tt=read();while(tt--){
		ll n=read();int m=read();
		// cout<<"n = "<<n<<" m = "<<m<<endl;
		if(n<A.size()){
			if(A[n].size()<=m)puts("0");
			else cout<<A[n][A[n].size()-m-1]<<'\n';
			continue;
		}
		else{
			for(int i=0;i<A.size();i++){
				if(A[i].size()<=m)continue;
				if((n&1)==(i&1))cout<<A[i][A[i].size()-m-1]<<'\n';
				else cout<<A[i+1][A[i+1].size()-m-1]<<'\n';
				break;
			}
		}
	}

	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 72ms
memory: 40508kb

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: 53ms
memory: 41436kb

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: 70ms
memory: 43068kb

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: 89ms
memory: 40508kb

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