-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTaroString.cpp
102 lines (81 loc) · 2.12 KB
/
TaroString.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// BEGIN CUT HERE
/*
SRM 613 Div2 Easy (250)
問題
-文字列Sが与えられる
-任意のアルファベットを全て除去することができる
-Sを“CAT”にできるかどうかを求める
*/
// END CUT HERE
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
using namespace std;
class TaroString {
public:
string getAnswer(string S) {
string s;
for (char c : S) {
switch (c) {
case 'C':
case 'A':
case 'T':
s += c;
break;
}
}
return s == "CAT" ? "Possible" : "Impossible";
}
// BEGIN CUT HERE
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const string &Expected, const string &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
public:
void run_test(int Case) {
int n = 0;
// test_case_0
if ((Case == -1) || (Case == n)){
string Arg0 = "XCYAZTX";
string Arg1 = "Possible";
verify_case(n, Arg1, getAnswer(Arg0));
}
n++;
// test_case_1
if ((Case == -1) || (Case == n)){
string Arg0 = "CTA";
string Arg1 = "Impossible";
verify_case(n, Arg1, getAnswer(Arg0));
}
n++;
// test_case_2
if ((Case == -1) || (Case == n)){
string Arg0 = "ACBBAT";
string Arg1 = "Impossible";
verify_case(n, Arg1, getAnswer(Arg0));
}
n++;
// test_case_3
if ((Case == -1) || (Case == n)){
string Arg0 = "SGHDJHFIOPUFUHCHIOJBHAUINUIT";
string Arg1 = "Possible";
verify_case(n, Arg1, getAnswer(Arg0));
}
n++;
// test_case_4
if ((Case == -1) || (Case == n)){
string Arg0 = "CCCATT";
string Arg1 = "Impossible";
verify_case(n, Arg1, getAnswer(Arg0));
}
n++;
}
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
TaroString ___test;
___test.run_test(-1);
}
// END CUT HERE