性感bfs在线求调教
查看原帖
性感bfs在线求调教
1269111
Eden_star楼主2024/11/13 16:12

第二个测试点wa了

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int cs[N],place[N];
int n,k,max_cs=0;
void bfs();
int main(){
	cin>>n>>k;
	bfs();
	/*for(int i=1;i<=n;i++){
		cout<<cs[i];
	}*/
	for(int i=1;i<=n;i++){
		max_cs=max(max_cs,cs[i]);
	}
	cout<<max_cs;
}
void bfs(){
	int l=0,r=1;
	while(l<r){
		//cout<<"1\n";
		if(cs[(place[l]+1)%n]==0){
			r++;
			place[r]=(place[l]+1)%n;
			cs[(place[l]+1)%n]=cs[place[l]]+1;
		}
		if(cs[(place[l]+k)%n]==0){
			r++;
			place[r]=(place[l]+k)%n;
			cs[(place[l]+k)%n]=cs[place[l]]+1;
		}
		l++;
	}
	return;
}
2024/11/13 16:12
加载中...