- 高士渠 的博客
模拟2003 T1
- @ 2025-8-28 22:07:35
乒乓球
http://www.turing-code.com/d/sqjx2025/p/CSPJ0301 这道题要模拟11分与21分直接输出,简单粗暴
#include<iostream>
#include<string>
using namespace std;
string s="",k;
int p1, p2;
void solve(int type){
p1=0,p2=0;
for (int i=0;s[i]!='E';i++){
if (s[i]=='W')p1++;
if (s[i]=='L')p2++;
if ((p1>=type||p2>=type)&&abs(p1-p2)>1){
cout<<p1<<":"<<p2<<endl;
p1=0;
p2=0;
}
}
cout<<p1<<":"<<p2<<endl;
}
int main(){
freopen("pingpong.in", "r", stdin),
freopen("pingpong.out", "w", stdout);
while(cin>>k)s+=k;
solve(11);
cout<<endl;
solve(21);
return 0;
}