当前位置:网站首页>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;
}
边栏推荐
- 为什么switch 的default后面要跟break?
- 693. Travel sequencing (map + topology)
- Characteristics of selenium
- Winter vacation daily question - lucky numbers in the matrix
- Error: eacces: permission denied, access to "/usr/lib/node_modules"
- D how to check null
- Why can't d link DLL
- [技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术
- 全屋Wi-Fi:一个谁也解决不好的痛点?
- What are eNB, EPC and PGW?
猜你喜欢

Drawing Nyquist diagram with MATLAB

Everyone believes that the one-stop credit platform makes the credit scenario "useful"

A better database client management tool than Navicat

Will your sleep service dream of the extra bookinfo on the service network

刚好1000粉丝,记录一下

Mysql5.7 installation super easy tutorial

What are eNB, EPC and PGW?

Node.js通过ODBC访问PostgreSQL数据库

Daily practice of C language --- monkeys divide peaches

Explanation: here is your UFO, Goldbach conjecture
随机推荐
Detailed collection of common MySQL commands
How to set QT manual layout
In 2021, the global TCB adapter revenue was about $93 million, and it is expected to reach $315.5 million in 2028
mysql ---- Oracle中的rownum转换成MySQL
错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
题解《子数整数》、《欢乐地跳》、《开灯》
[youcans' image processing learning course] general contents
Qt-制作一个简单的计算器-实现四则运算-将结果以对话框的形式弹出来
Achievements in science and Technology (27)
In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028
【模板】最长公共子序列 (【DP or 贪心】板子)
[cloud native database] what to do when encountering slow SQL (Part 1)?
Quantum three body problem: Landau fall
Téléchargement par navigateur
为什么switch 的default后面要跟break?
SystemServer进程
无主灯设计:如何让智能照明更加「智能」?
[true topic of the Blue Bridge Cup trials 43] scratch space flight children's programming explanation of the true topic of the Blue Bridge Cup trials
Pocket Raider comments
Engineers who can't read device manuals are not good cooks