-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2191A.cpp
More file actions
38 lines (28 loc) · 712 Bytes
/
2191A.cpp
File metadata and controls
38 lines (28 loc) · 712 Bytes
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
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios::sync_with_stdio(false); cin.tie(nullptr);
int main() {
fast_io;
int t;
cin >> t;
while (t--) {
// solve here
int n;
cin >> n;
vector<int> a(n);
vector<int> pos(n + 1);
for(int i = 0; i < n; i++) {
cin >> a[i];
pos[a[i]] = i;
}
bool ok = true;
for(int i = 1; i < n; i++) {
if(abs(pos[i] - pos[i+1]) % 2 == 0) {
ok = false;
break;
}
}
cout << (ok ? "YES" : "NO") << endl;
}
return 0;
}