-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluckyboundary.cpp
69 lines (52 loc) · 1.16 KB
/
luckyboundary.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<iostream>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define lli long long int
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test;
cin>>test;
while(test--){
int n;
cin>>n;
lli a[n];
vector<int> v;
int flag= 0;
static lli temp;
for(lli i=0; i<n; i++){
cin>>a[i];
if( i>0 && a[i]<a[i-1]){
flag= 1;
temp= i;
}
if(flag==1){
v.push_back(a[i]);
}
}
for(lli i=0; i<temp; i++){
v.push_back(a[i]);
}
lli t1= 0;
for(auto i= v.begin(); i!=v.end(); i++){
t1++;
if(*i>*(i+1) && i<v.end()){
cout<<"NO\n";
break;
}
int t= v.size();
if(t1==t){
cout<<"YES\n";
cout<<"1\n";
}
}
};
return 0;
}