当前位置:网站首页>P1042 [noip2003 popularization group] Table Tennis
P1042 [noip2003 popularization group] Table Tennis
2022-07-02 13:56:00 【Fu Fushou grass】
Pit point 1:E Will appear anywhere , Not necessarily the end .
Pit point 2: The difference between winning and losing must be greater than or equal to 2 site
Pit point 3: Read E when , Whether the score is zero or not , All output
String emulation version :
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
void solve() {
string s;
char c = cin.get();
while (c != 'E') {
if (c == 'W' || c == 'L') s += c;
c = cin.get();
}
int w = 0, l = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'W') {
w++;
} else if (s[i] == 'L') {
l++;
}
if (abs(w - l) >= 2 && (w >= 11 || l >= 11)) {
cout << w << ":" << l << "\n";
w = l = 0;
}
}
cout << w << ":" << l << "\n\n";
w = l = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'W') {
w++;
} else if (s[i] == 'L') {
l++;
}
if (abs(w - l) >= 2 && (w >= 21 || l >= 21)) {
cout << w << ":" << l << "\n";
w = l = 0;
}
}
cout << w << ":" << l << "\n";
}
int32_t main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int tt(1);
//std::cin >> tt;
while (tt--) {
solve();
}
return 0;
}
Array emulation version :
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
constexpr int N = 2500 * 30;
int win[N];
void solve() {
char c = cin.get();
int tot = 0;
while (c != 'E') {
if (c == 'W') {
win[tot++] = 1;
} else if (c == 'L') {
win[tot++] = 2;
}
c = cin.get();
}
int w = 0, l = 0;
for (int i = 0; i <= tot; i++) {
if (win[i] == 1) {
w++;
} else if (win[i] == 2) {
l++;
}
if (i == tot || abs(w - l) >= 2 && (w >= 11 || l >= 11)) {
cout << w << ":" << l << "\n";
w = l = 0;
}
}
cout << "\n";
for (int i = 0; i <= tot; i++) {
if (win[i] == 1) {
w++;
} else if (win[i] == 2) {
l++;
}
if (i == tot || abs(w - l) >= 2 && (w >= 21 || l >= 21)) {
cout << w << ":" << l << "\n";
w = l = 0;
}
}
cout << "\n";
}
int32_t main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int tt(1);
//std::cin >> tt;
while (tt--) {
solve();
}
return 0;
}
边栏推荐
- Engineers who can't read device manuals are not good cooks
- Characteristics of selenium
- On flow delivery between microservices
- Achievements in science and Technology (27)
- Selenium, element operation and browser operation methods
- Download files and preview pictures
- 2022 Heilongjiang provincial examination on the writing skills of Application Essays
- How to set QT manual layout
- 如何设置Qt手工布局
- Everyone believes that the one-stop credit platform makes the credit scenario "useful"
猜你喜欢

2022 Heilongjiang provincial examination on the writing skills of Application Essays

Explanation: here is your UFO, Goldbach conjecture

BeanUtils--浅拷贝--实例/原理

Common options of tcpdump command: Three

Qt-制作一个简单的计算器-实现四则运算

题解:《你的飞碟在这儿》、《哥德巴赫猜想》

Pointer from entry to advanced (1)

selenium 在pycharm中安装selenium

Chaos engineering platform chaosblade box new heavy release

ensp简单入门
随机推荐
How to explain binary search to my sister? This is really difficult, fan!
P3807 [template] Lucas theorem /lucas theorem
[Blue Bridge Cup] children's worship circle
Origin绘制热重TG和微分热重DTG曲线
Android kotlin fragment technology point
Countermeasures for the failure of MMPV billing period caused by negative inventory of materials in SAP mm
Pointer from entry to advanced (1)
P1347 排序(拓扑 + spfa判断环 or 拓扑[内判断环])
In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028
How much do you know about free SSL certificates? The difference between free SSL certificate and charged SSL certificate
Browser driven Download
Partner cloud form strong upgrade! Pro version, more extraordinary!
rxjs Observable 自定义 Operator 的开发技巧
Pocket Raider comments
Selenium element positioning method
Find love for speed in F1 delta time Grand Prix
Let juicefs help you with "remote backup"
错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
Why is the default of switch followed by break?
Just 1000 fans, record it