-
Notifications
You must be signed in to change notification settings - Fork 0
/
1133.cpp
63 lines (60 loc) · 1.34 KB
/
1133.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
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;
int main()
{
string s;
cin>>s;
int nums[4] = {0};
for(int i=0;i<s.size();++i){
if(s[i]=='S'){
nums[0]++;
}
else if(s[i]=='T'){
nums[1]++;
}
else if(s[i]=='A'){
nums[2]++;
}
else if(s[i]=='R'){
nums[3]++;
}
}
cout<<nums[0]*nums[1]*nums[2]*nums[3]<<' ';
int res = min(nums[0], min(nums[1], min(nums[2], nums[3])));
cout<<res<<' ';
int cnt = 0;
int cnt_tmp = 4;
vector<int> v(s.size(), false);
for(int i=0;i<res;++i){
cnt_tmp = 4;
for(int j=0;j<s.size();++j){
if(s[j]=='S' && !visited[j]){
if(cnt_tmp==4){
cnt_tmp--;
visited[j] = true;
}
}else if(s[j]=='T' && !visited[j]){
if(cnt_tmp==3){
cnt_tmp--;
visited[j] = true;
}
}else if(s[j]=='A' && !visited[j]){
if(cnt_tmp==2){
cnt_tmp--;
visited[j] = true;
}
}else if(s[j]=='R' && !visited[j]){
if(cnt_tmp==1){
cnt_tmp--;
visited[j] = true;
++cnt;
}
}
}
}
cout<<cnt<<endl;
return 0;
}