-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayFix.cpp
More file actions
46 lines (39 loc) · 896 Bytes
/
Copy pathArrayFix.cpp
File metadata and controls
46 lines (39 loc) · 896 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
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> a(n),b;
for(int i=0;i<n;i++){
cin>>a[i];
}
if(is_sorted(a.begin(),a.end())){
cout<<"YES"<<endl;
continue;
}
// bool ok =true;
b.push_back(a.back());
for(int i=n-2;i>=0;i--){
if(a[i]>=10 && a[i]>b.back()){
int r = a[i]%10;
int q =a[i]/10;
b.push_back(r);
b.push_back(q);
}
else{
b.push_back(a[i]);
}
}
reverse(b.begin(),b.end());
if(is_sorted(b.begin(),b.end())){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
}