当前位置:网站首页>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;
}
边栏推荐
- QT new project_ MyNotepad++
- Android kotlin fragment technology point
- selenium,元素操作以及浏览器操作方法
- Drawing Nyquist diagram with MATLAB
- (POJ - 1984) navigation nightare (weighted and search set)
- What are the classifications of SSL certificates? How to choose the appropriate SSL certificate?
- selenium 在pycharm中安装selenium
- Pocket Raider comments
- Dingtalk send message
- 你的 Sleep 服务会梦到服务网格外的 bookinfo 吗
猜你喜欢
Qt新项目_MyNotepad++
使用BLoC 构建 Flutter的页面实例
OpenFOAM:lduMatrix&lduAddressing
Téléchargement par navigateur
Selenium installing selenium in pycharm
Engineers who can't read device manuals are not good cooks
Can automatically update the universal weekly report template, you can use it with your hand!
Error: eacces: permission denied, access to "/usr/lib/node_modules"
错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
题解:《压缩技术》(原版、续集版)
随机推荐
石子合并板子【区间DP】(普通石子合并 & 环形石子合并)
如何设置Qt手工布局
Design of non main lamp: how to make intelligent lighting more "intelligent"?
c# 水晶报表打印
Common options of tcpdump command: Three
P1908 逆序对
Winter vacation daily question - lucky numbers in the matrix
How to explain binary search to my sister? This is really difficult, fan!
Sum of the first n terms of Fibonacci (fast power of matrix)
BeanUtils -- shallow copy -- example / principle
【模板】最长公共子序列 (【DP or 贪心】板子)
Launcher启动过程
Will your sleep service dream of the extra bookinfo on the service network
[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Integral link, inertia link and proportion link in Simulink
量子三体问题: Landau Fall
Which do you choose between Alibaba P7 with an annual salary of 900000 and deputy department level cadres?
Clean up system cache and free memory under Linux
Three talking about exception -- error handling