-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1874.cpp
More file actions
41 lines (36 loc) · 754 Bytes
/
1874.cpp
File metadata and controls
41 lines (36 loc) · 754 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
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main()
{
io;
int N;
cin>>N;
vector<int> input(N);
stack<int> s;
vector<string> result;
bool p=true;
for(int i=0;i<N;i++){
cin>>input[i];
}
int i=1,top=0;
while(top<N){
while(i<=N&&(s.empty()||s.top()!=input[top])){
s.push(i++);
result.push_back("+\n");
}
if(!s.empty()&&s.top()==input[top]){
s.pop();
result.push_back("-\n");
}else{
cout<<"NO";
return 0;
}
top++;
}
for(string &s:result) cout<<s;
return 0;
}