P1042 乒乓球

字符串string的基本使用

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <ctime> using namespace std;
static const auto y = []() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
return 0;
}(); void pro1();
int main() {
pro1();
return 0;
}
void pro1() {
string str;
vector<string> strs;
strs.reserve(2500);
while (true){
getline(cin, str);
if(str.length()==0)break;
strs.push_back(str);
}
int role1=0,role2=0;
bool flag = true;
for (int i = 0; i < strs.size(); ++i) {
for (int j = 0; j < strs[i].size(); ++j) {
if(strs[i][j]=='E'){
cout<<role1<<":"<<role2;
role1=0,role2=0;
flag = false;
break;
}
strs[i][j]=='W'?role1+=1:NULL;
strs[i][j]=='L'?role2+=1:NULL;
if((role1>=11||role2>=11) && abs(role1-role2) >= 2){
cout<<role1<<":"<<role2<<endl;
role1=0,role2=0;
}
}
if(!flag)break;
}
flag = true;
cout<<endl;
cout<<endl;
for (int i = 0; i < strs.size(); ++i) {
for (int j = 0; j < strs[i].size(); ++j) {
if(strs[i][j]=='E'){
cout<<role1<<":"<<role2;
role1=0,role2=0;
flag = false;
break;
}
strs[i][j]=='W'?role1+=1:NULL;
strs[i][j]=='L'?role2+=1:NULL;
if((role1>=21||role2>=21) && abs(role1-role2) >= 2){
cout<<role1<<":"<<role2<<endl;
role1=0,role2=0;
}
}
if(!flag)break;
} }

模拟、字符串--P1042 乒乓球 题解的更多相关文章

  1. 二叉搜索树的结构(30 分) PTA 模拟+字符串处理 二叉搜索树的节点插入和非递归遍历

    二叉搜索树的结构(30 分) PTA 模拟+字符串处理 二叉搜索树的节点插入和非递归遍历   二叉搜索树的结构(30 分) 二叉搜索树或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则 ...

  2. 洛谷 P1042 乒乓球

    P1042 乒乓球 var s:string; a1:array[1..50000] of char; i,n,x,y:longint; procedure f1; begin while not e ...

  3. 模拟/字符串处理 UVALive 6833 Miscalculatio

    题目传送门 /* 模拟/字符串处理:主要是对*的处理,先把乘的预处理后再用加法,比如说是:1+2*3+4 = 1+..6+4 = 11 */ #include <cstdio> #incl ...

  4. 洛谷P1042 乒乓球【模拟】

    题目背景 国际乒联现在主席沙拉拉自从上任以来就立志于推行一系列改革,以推动乒乓球运动在全球的普及.其中111111分制改革引起了很大的争议,有一部分球员因为无法适应新规则只能选择退役.华华就是其中一位 ...

  5. TZOJ 4865 统计单词数(模拟字符串)

    描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次数. 现在,请你编程实现这一功能,具体要求是:给定一个单词,请你输出它在给定的 ...

  6. PAT L2-008 最长对称子串(模拟字符串)

    对给定的字符串,本题要求你输出最长对称子串的长度.例如,给定Is PAT&TAP symmetric?,最长对称子串为s PAT&TAP s,于是你应该输出11. 输入格式: 输入在一 ...

  7. POJ 1016 模拟字符串

    Numbers That Count Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20396   Accepted: 68 ...

  8. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  9. java基础知识回顾之---java String final类普通方法的应用之“模拟字符串Trim方法”

    /* * 4,模拟一个trim功能一致的方法.去除字符串两端的空白  * 思路: * 1,定义两个变量. * 一个变量作为从头开始判断字符串空格的角标.不断++. * 一个变量作为从尾开始判断字符串空 ...

随机推荐

  1. 基于FBX SDK的FBX模型解析与加载 -(二)

    http://blog.csdn.net/bugrunner/article/details/7211515 5. 加载材质 Material是一个模型渲染时必不可少的部分,当然,这些信息也被存到了F ...

  2. MAC下如何配置Android手机调试(将测试手机加入到Mac系统的调试列表中)

    第一步: 查看usb设备信息 在 终端输入:system_profiler SPUSBDataType     可以查看连接的usb设备的信息 比如我的usb信息如下(部分内容): 查看到我的Andr ...

  3. Eclipse新建Maven webapp项目错误的解决方法

    新建webapp项目时出现如下错误: 解决步骤如下: 1.  右键点击项目,选择Properties,点击Java Build Path,将默认的JRE移除,点击右侧add Library,选择JRE ...

  4. 进程动态拦截注入API HOOK

    最近工作中遇到一个问题,需要通过程序界面进行判断程序的运行状态,刚开始认为很简单,不就是一个窗体控件获取,获取Button的状态和Text.刚好去年干过该事情,就没太在意,就把优先级排到后面了,随着项 ...

  5. C# 多线程(转)

    C#多线程   一.基本概念 1.进程 首先打开任务管理器,查看当前运行的进程: 从任务管理器里面可以看到当前所有正在运行的进程.那么究竟什么是进程呢? 进程(Process)是Windows系统中的 ...

  6. two_sum问题

    def two_sum(li, target): for i in range(len(li)): for j in range(i+1, len(li)): if li[i] + li[j] == ...

  7. _bzoj1911 [Apio2010]特别行动队【斜率优化dp】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1911 裸的斜率优化dp. #include <cstdio> const int ...

  8. The 17th Zhejiang University Programming Contest Sponsored by TuSimple A

    Marjar Cola Time Limit: 1 Second      Memory Limit: 65536 KB Marjar Cola is on sale now! In order to ...

  9. Analyzing Polyline CodeForces - 195D

    Analyzing Polyline CodeForces - 195D 题意:有n个函数,第i个函数yi(x)=max(ki*x+bi,0).定义函数s(x)=y1(x)+y2(x)+...+yn( ...

  10. 微信小程序开发常见的拉起外部地图软件进行导航的功能

    <view class="dh" bindtap="mapNavigation" data-addr="{{address}}"> ...