为啥我的代码输入不行?
查看原帖
为啥我的代码输入不行?
1494435
xiaoshewanMC楼主2024/10/5 17:55

为啥我的代码输入不行?

#include<bits/stdc++.h>
using namespace std;
int a[10010],n,t,b[10010],c[10010];
bool check(int x){
	for(int i=0;i<n;i++)
		if(i<x)b[i]=a[i];
		else c[i-x+1]=a[i];
	if(x<=n/2)
		for(int i=0;i<n-x;i++)
			if(c[i]==b[0]){
				int i2=i;
				while(c[i2]==b[i2-i]&&i2-i<x)i2++;
				if(i2-i==x)return 0;
			}
	else
		for(int i=0;i<x;i++)
			if(b[i]==c[0]){
				int i2=i;
				while(b[i2]==c[i2-i]&&i2-i<x)i2++;
				if(i2-i==x)return 0;
			}
	return 1;
}
int main(){
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>n;
		for(int j=0;j<n;i++)cin>>a[i];
		for(int j=1;j<n-1;j++)
			if(check(j)){
				cout<<"YES";
				break;
			}
		cout<<"NO";
	}
	return 0;
}
2024/10/5 17:55
加载中...