-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva1062.cpp
More file actions
41 lines (36 loc) · 760 Bytes
/
uva1062.cpp
File metadata and controls
41 lines (36 loc) · 760 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
/* Rishikesh
* UVA 1062
*/
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
using namespace std;
int getNumStacks(string& contType) {
vector<stack<char>> st;
for(auto c : contType) {
size_t i = 0;
bool failed = true;
for(;i < st.size(); i++) {
if (st[i].top() >= c) {
st[i].push(c);
failed = false;
break;
}
}
if (failed) {
stack<char> t; t.push(c);
st.push_back(t);
}
}
return st.size();
}
int main() {
int i = 1;
string s;
while(cin >> s, s != "end") {
cout << "Case " << i << ": " << getNumStacks(s) << endl;
i++;
}
}