-
Notifications
You must be signed in to change notification settings - Fork 1
/
1062 - Containers.cpp
71 lines (58 loc) · 1.02 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*input
A
CBACBACBACBACBA
CCCCBBBBAAAA
ACMICPC
end
*/
#include <stdio.h>
#include <cmath>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string.h>
#include <stack>
using namespace std;
#define SSTR( x ) dynamic_cast< std::ostringstream & >( \
( std::ostringstream() << std::dec << x ) ).str()
#define FOR(a , b) for ( int i = a ; i < b ; i++ )
#define FOR2(a , b) for ( int j = a ; j < b ; j++ )
typedef long long ll;
typedef std::pair<int,int> ii;
int main()
{
stack<char> arr[1000];
string in;
ios::sync_with_stdio(false);
cin >> in;
int cas = 1;
while (in.compare("end") != 0)
{
FOR(0 , 1000)
arr[i].push('0');
int count = 0, index;
FOR(0 , in.size())
{
FOR2(0, 1000)
{
if(arr[j].top() == '0')
{
index = j;
count++;
break;
}
else if(arr[j].top() >= in[i])
{
index = j;
break;
}
}
arr[index].push(in[i]);
}
cout <<"Case "<< cas << ": " <<count << endl;
cas++;
cin >> in;
}
}