This repository was archived by the owner on May 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1321.cpp
More file actions
70 lines (69 loc) · 2.84 KB
/
P1321.cpp
File metadata and controls
70 lines (69 loc) · 2.84 KB
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
//
// Created by RenAhsAcme on 2026/4/18.
//
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = " ";
getline(cin, s);
int boy_num = 0, girl_num = 0;
int ptr = 0;
while (s.find("boy", ptr) != string::npos) {
ptr = static_cast<int>(s.find("boy", ptr)), s[ptr] = '.', s[ptr + 1] = '.', s[ptr + 2] = '.';
boy_num++, ptr += 3;
}
ptr = 0;
while (s.find("girl", ptr) != string::npos) {
ptr = static_cast<int>(s.find("girl", ptr)), s[ptr] = '.', s[ptr + 1] = '.';
s[ptr + 2] = '.', s[ptr + 3] = '.', girl_num++, ptr += 4;
}
ptr = 0;
while (s.find("irl", ptr) != string::npos) {
ptr = static_cast<int>(s.find("irl", ptr)), s[ptr] = '.', s[ptr + 1] = '.', s[ptr + 2] = '.';
girl_num++, ptr += 3;
}
ptr = 0;
while (s.find("gir", ptr) != string::npos) {
ptr = static_cast<int>(s.find("gir", ptr)), s[ptr] = '.', s[ptr + 1] = '.', s[ptr + 2] = '.';
girl_num++, ptr += 3;
}
ptr = 0;
while (s.find("bo", ptr) != string::npos)
ptr = static_cast<int>(s.find("bo", ptr)), s[ptr] = '.', s[ptr + 1] = '.', boy_num++, ptr += 2;
ptr = 0;
while (s.find("oy", ptr) != string::npos)
ptr = static_cast<int>(s.find("oy", ptr)), s[ptr] = '.', s[ptr + 1] = '.', boy_num++, ptr += 2;
ptr = 0;
while (s.find("gi", ptr) != string::npos)
ptr = static_cast<int>(s.find("gi", ptr)), s[ptr] = '.', s[ptr + 1] = '.', girl_num++, ptr += 2;
ptr = 0;
while (s.find("ir", ptr) != string::npos)
ptr = static_cast<int>(s.find("ir", ptr)), s[ptr] = '.', s[ptr + 1] = '.', girl_num++, ptr += 2;
ptr = 0;
while (s.find("rl", ptr) != string::npos)
ptr = static_cast<int>(s.find("rl", ptr)), s[ptr] = '.', s[ptr + 1] = '.', girl_num++, ptr += 2;
ptr = 0;
while (s.find("b", ptr) != string::npos)
ptr = static_cast<int>(s.find("b", ptr)), s[ptr] = '.', boy_num++, ptr += 1;
ptr = 0;
while (s.find("o", ptr) != string::npos)
ptr = static_cast<int>(s.find("o", ptr)), s[ptr] = '.', boy_num++, ptr += 1;
ptr = 0;
while (s.find("y", ptr) != string::npos)
ptr = static_cast<int>(s.find("y", ptr)), s[ptr] = '.', boy_num++, ptr += 1;
ptr = 0;
while (s.find("g", ptr) != string::npos)
ptr = static_cast<int>(s.find("g", ptr)), s[ptr] = '.', girl_num++, ptr += 1;
ptr = 0;
while (s.find("i", ptr) != string::npos)
ptr = static_cast<int>(s.find("i", ptr)), s[ptr] = '.', girl_num++, ptr += 1;
ptr = 0;
while (s.find("r", ptr) != string::npos)
ptr = static_cast<int>(s.find("r", ptr)), s[ptr] = '.', girl_num++, ptr += 1;
ptr = 0;
while (s.find("l", ptr) != string::npos)
ptr = static_cast<int>(s.find("l", ptr)), s[ptr] = '.', girl_num++, ptr += 1;
cout << boy_num << endl << girl_num << endl;
return 0;
}