-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1062_Containers.cpp
47 lines (44 loc) · 979 Bytes
/
1062_Containers.cpp
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
#include<iostream>
#include<string>
#include<stack>
#include<vector>
using namespace std;
int diff(string s){
bool check[91] = {};
int count = 0;
for(auto c: s){
if(!check[c]){
check[c] = true;
count++;
}
}
return count;
}
int main(){
int test = 0;
string s;
while(cin >> s && s != "end"){
test++;
int d = diff(s);
vector<stack<char>> v;
for(auto c: s){
int i;
for(i = 0; i < v.size(); i++){
if(v[i].top() >= c){
v[i].push(c);
break;
}
}
if(i == v.size()){
stack<char> st;
st.push(c);
v.push_back(st);
}
if(d < v.size()) break;
}
cout << "Case "<<test<<": ";
if(d < v.size()) cout << d << endl;
else cout << v.size() << endl;
}
return 0;
}