-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bazoka and Mocha's Array
67 lines (58 loc) · 1.16 KB
/
Bazoka and Mocha's Array
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
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
ll a[n];
vector<ll> b(n), c;
for (ll i = 0; i < n; i++)
{
cin >> a[i];
b[i] = a[i];
}
sort(b.begin(), b.end());
int index = n;
for (ll i = 1; i < n; i++)
{
if (a[i] < a[i - 1])
{
index = i;
}
}
for (int i = index; i < n; i++)
{
c.push_back(a[i]);
}
for (int i = 0; i < index; i++)
{
c.push_back(a[i]);
}
int nhi = 0;
for (int i = 0; i < n; i++)
{
if (c[i] != b[i])
{
cout << "NO" << endl;
nhi = 1;
break;
}
}
if (!nhi)
cout << "YES" << endl;
// if (count == 1 || count == 0)
// {
// cout << "YES" << endl;
// }
// else
// {
// cout << "NO" << endl;
// }
}
}