-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1049.cpp
More file actions
executable file
·42 lines (38 loc) · 802 Bytes
/
Copy path1049.cpp
File metadata and controls
executable file
·42 lines (38 loc) · 802 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
/**
* 栈模拟
**/
#include <iostream>
using namespace std;
int tmp, nex, flag = 1;
struct sstack
{
int a[1233];
int top;
};
int main() {
int T;
cin >> T;
for(int i = 0;i < T;++ i) {
int N, M;
nex = 0; flag = 1;
cin >> N >> M;
sstack s;
s.top = 0; s.a[0] = nex;
for(int i = 0;i < N;++ i) {
cin >> tmp;
while(flag) {
if(s.a[s.top] == tmp) {
-- s.top;
break;
}
++ s.top;
++ nex;
if(nex + 1 > N) flag = 0;
s.a[s.top] = nex;
if(s.top > M) flag = 0;
}
}
if(flag) cout << "YES" << endl;
else cout << "NO" << endl;
}
}