-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathc.cpp
More file actions
49 lines (43 loc) · 1.01 KB
/
c.cpp
File metadata and controls
49 lines (43 loc) · 1.01 KB
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
#include <iostream>
#include <vector>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
// 다르면 눕혀봤자 대칭 아님
if (a[1] != n) {
cout << "NO" << '\n';
continue;
}
// 옆으로 눕히는 부분
vector<int> b;
for (int i = n; i >= 1; i--) {
while (b.size() < a[i]) {
// index i를 삽입
b.push_back(i);
}
}
// for(int i = 0; i < b.size(); i++){
// cout<<b[i]<<" ";
// }cout<<"\n";
bool meow = true;
for (int i = 1; i <= n; i++) {
if (a[i] != b[i - 1]) {
cout << "NO" << '\n';
meow = false;
break;
}
}
if (meow) {
cout << "YES" << '\n';
}
}
return 0;
}