Repository navigation
Expand file tree
/
Copy path1062.cpp
More file actions
80 lines (66 loc) · 1.53 KB
/
Copy path1062.cpp
File metadata and controls
80 lines (66 loc) · 1.53 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
using namespace std;
int main()
{
int N, chefe[1001];
bool parar = false;
while(scanf("%d",&N))
{
if(N == 0)
{
break;
}
while(true)
{
int i, j;
stack <int> vag;
for(i = 1; i <= N; i++)
{
scanf("%d",&chefe[i]);
if(chefe[i] == 0)
{
parar = true;
printf("\n");
break;
}
}
i = 1;
j = 1;
while(true)
{
for(i = 1; i <= N; i++)
{
if(!vag.empty() && vag.top() == chefe[i])
{
vag.pop();
}
else if(j <= N)
{
vag.push(j);
j++;
if(vag.top() == chefe[i])
{
vag.pop();
}
}
else
{
parar = true;
break;
}
}
i++;
}
if (parar)
printf("\n");
if(vag.empty())
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}