-
Notifications
You must be signed in to change notification settings - Fork 0
/
B_Array_Fix.cpp
56 lines (50 loc) · 975 Bytes
/
B_Array_Fix.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
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,j,n) for(int i=j; i<n; i++)
#define fo(i,j) for(auto i: j)
#define vec vector<int>
void solve() {
int n;
cin >> n;
vec v(n);
f(i,0,n) {
cin >> v[i];
}
vec ans;
f(i,0,n) {
if(v[i] < 10) {
ans.push_back(v[i]);
} else {
int num = v[i];
stack<int> s;
while (num != 0)
{
s.push(num%10);
num = num/10;
}
while (!s.empty())
{
int top = s.top();
s.pop();
ans.push_back(top);
}
}
}
f(i,0,ans.size()) {
if(ans[i] > ans[i+1]) {
cout << "NO" << endl;
return;
}
}
cout << "YES" << endl;
}
signed main(){
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}