-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4151.cpp
More file actions
executable file
·50 lines (46 loc) · 980 Bytes
/
Copy path4151.cpp
File metadata and controls
executable file
·50 lines (46 loc) · 980 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
47
48
49
50
/**
* 栈模拟
* 为什么每道题都要快读TATTTTT
**/
#include <iostream>
#include <stdio.h>
using namespace std;
int tmp, nex, flag = 1;
struct sstack
{
int a[1000233];
int top;
};
void read(int &x){
x = 0;
char ch;
while (ch = getchar(), (ch < '0' || ch > '9'));
x = ch - '0';
while(ch = getchar(), ch >= '0' && ch <= '9') x = 10 * x + ch - '0';
}
int main() {
int T;
cin >> T;
for(int i = 0;i < T;++ i) {
int N;
nex = 0; flag = 1;
read(N);
sstack s;
s.top = 0; s.a[0] = nex;
for(int i = 0;i < N;++ i) {
read(tmp);
while(flag) {
if(s.a[s.top] == tmp - 1) {
-- s.top;
break;
}
++ s.top;
++ nex;
if(nex + 1 > N) flag = 0;
s.a[s.top] = nex;
}
}
if(flag) printf("Yes\n");
else printf("No\n");
}
}