当前位置:网站首页>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;
}
边栏推荐
- Mysql5.7 installation super easy tutorial
- Explanation: here is your UFO, Goldbach conjecture
- Partner cloud form strong upgrade! Pro version, more extraordinary!
- Tupang multi-target tracking! BOT sort: robust correlated multi pedestrian tracking
- Just 1000 fans, record it
- Integral link, inertia link and proportion link in Simulink
- 693. Travel sequencing (map + topology)
- Use bloc to build a page instance of shutter
- [Blue Bridge Cup] children's worship circle
- Download files and preview pictures
猜你喜欢

Drawing Nyquist diagram with MATLAB

Origin绘制热重TG和微分热重DTG曲线

QT - make a simple calculator - realize four operations

Bridge of undirected graph

Use of UIC in QT

题解:《压缩技术》(原版、续集版)

Téléchargement par navigateur

Find love for speed in F1 delta time Grand Prix

Don't spend money, spend an hour to build your own blog website

selenium,元素操作以及浏览器操作方法
随机推荐
Téléchargement par navigateur
Why is the default of switch followed by break?
Getting started with QT - making a simple calculator
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
Will your sleep service dream of the extra bookinfo on the service network
Astro learning notes
Unity small map production [2]
Sum of the first n terms of Fibonacci (fast power of matrix)
Explanation: here is your UFO, Goldbach conjecture
Story points vs. human days
ArrayList and LinkedList
D如何检查null
题解《子数整数》、《欢乐地跳》、《开灯》
Error function ERF
2022 zero code / low code development white paper [produced by partner cloud] with download
混沌工程平台 ChaosBlade-Box 新版重磅发布
无主灯设计:如何让智能照明更加「智能」?
Tupang multi-target tracking! BOT sort: robust correlated multi pedestrian tracking
大家信夫一站式信用平台让信用场景“用起来
Selenium element positioning method