当前位置:网站首页>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;
}
边栏推荐
- Halcon extract orange (Orange)
- Pointer from entry to advanced (1)
- OpenFOAM:lduMatrix&lduAddressing
- P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
- Three talking about exception -- error handling
- selenium 在pycharm中安装selenium
- Codeforces Round #803 (Div. 2)(A~D)
- [USACO05JAN]Watchcow S(欧拉回路)
- 不会看器件手册的工程师不是个好厨子
- 验证失败,请检查您的回电网址。您可以按照指导进行操作
猜你喜欢
OpenFOAM:lduMatrix&lduAddressing
Selenium installing selenium in pycharm
刚好1000粉丝,记录一下
Code implementation MNLM
BeanUtils -- shallow copy -- example / principle
【虹科技术分享】如何测试 DNS 服务器:DNS 性能和响应时间测试
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
Daily practice of C language --- monkeys divide peaches
Just 1000 fans, record it
无主灯设计:如何让智能照明更加「智能」?
随机推荐
科技的成就(二十七)
Slashgear shares 2021 life changing technology products, which are somewhat unexpected
What are eNB, EPC and PGW?
693. Travel sequencing (map + topology)
Solve "sub number integer", "jump happily", "turn on the light"
Mysql5.7 installation super easy tutorial
Dingtalk 发送消息
mysql ---- Oracle中的rownum转换成MySQL
Use bloc to build a page instance of shutter
混沌工程平台 ChaosBlade-Box 新版重磅发布
BeanUtils--浅拷贝--实例/原理
Unity skframework framework (XII), score scoring module
刚好1000粉丝,记录一下
Android kotlin fragment technology point
D language, possible 'string plug-ins'
Node. JS accessing PostgreSQL database through ODBC
Will your sleep service dream of the extra bookinfo on the service network
Quantum three body problem: Landau fall
How to use SAP's metadata framework (MDF) to build custom business rules?
Qt-制作一个简单的计算器-实现四则运算