C. Nastya and Strange Generator (思维&找规律)

题目传送门

思路:

AC代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		vector<int>a(n+1);
		for(int i=1;i<=n;i++) scanf("%d",&a[i]);
		int ok=1;
		for(int i=2;i<=n;i++)	
			if(a[i]>a[i-1]&&a[i]-a[i-1]!=1){
				ok=0;
				break;
			}
		puts(ok?"Yes":"No");
	}
	return 0;
}