NOIP 2003 Table Tennis

Luo Gu P1042 Table Tennis

https://www.luogu.org/problemnew/show/P1042

JDOJ 1363: [NOIP2003] tennis T1

https://neooj.com:8082/oldoj/problem.php?id=1363

Topic background

Sharara ITTF President of now since he took office determined to implement a series of reforms to promote the popularization of table tennis in the world. Of which 11 1 1 min reform caused a great controversy, in part because they can not adapt to the new rules the players can only choose to retire. Chihuahua is one of them, he embarked on a work table tennis after retiring, intent to figure out 11 1 1 point and made 21 2 1 point differential impact on system players. Prior to carry out his research, he first needs to do some analysis of the statistics of his game for years, so they need your help.

Title Description

China and China carried out by the analysis, the first ball of the outcome of each game uses a list, and then calculate at 11 1 1-point and 21 2 under 1-point game results from the two (as of end of record).

For example, now we have such a record, (which Wrepresents China and China get one point, Lrepresents China and China opponent gains a point):

WWWWWWWWWWWWWWWWWWWWWWLW

In . 11 1 for 1-point, then the result of the game is the first game huahua . 11 1 1 to 0 wins 0, the second game . 11 1 1 to 0 0 wins, the third game in progress, the current score of 1 to 1 1 1. In 21 is 2 for 1-point, when the game was the first game Chihuahua 21 is 2 1 to 0 1-0 win, being the second game, the score 2 2 to 1 1. If a game has just started, this time the score was 0 1-0 0 0 Minutes until the difference is equal to or greater than 2 2 before the end of a game.

Your program is to match the input range of information ( WL W L form), to output the correct result.

Input and output formats

Input formats:

 

Each file contains a plurality of input lines of character strings, the string of uppercase W is W is, L L, and E E composition. Where E E represents the end of the game information, the program should ignore everything after the E.

 

Output formats:

 

Output consists of two parts, each part has a plurality of rows, each row corresponding to the score of a game (game information input by the order). Wherein the first part is . 11 1 results in the 1-point, the second part 21 is 2 results in the 1-point, separated by a blank line between the two parts.

 

Sample input and output

Input Sample # 1:  Copy
WWWWWWWWWWWWWWWWWWWW
WWLWE
Output Sample # 1:  Copy
11:0
11:0
1:1

21:0
2:1

Explanation

Up to 25 characters per line, up to 2500 rows

 

The hardest popularity of group T1? Ha ha ha

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
string s[100001];
int a[100001],b[100001],a2[100001],b2[100001];
bool check(int x)
{
    int t=s[x].size();
    for(int i=0;i<t;i++)
    if(s[x][i]=='E')return 0;
    return 1;
}
int main()
{
    int n=1,i,j,t=1,t2=1;
    cin>>s[n];
    while(check(n))
    {
        n++;
        cin>>s[n];
    }
    for(i=1;i<=n;i++)
    {
        int sz=s[i].size();
        for(j=0;j<sz;j++)
        {
            if(s[i][j]=='E')
            {
                for(i=1;i<=t;i++)
                    cout<<a[i]<<":"<<b[i]<<endl;
                cout<<endl;
                for(i=1;i<=t2;i++)
                    cout<<a2[i]<<":"<<b2[i]<<endl;
                return 0;
            }
            if(s[i][j]=='W')
                a[t]++,a2[t2]++;
            else if(s[i][j]=='L')
                b[t]++,b2[t2]++;
            if((a[t]>=11||b[t]>=11)&&abs(a[t]-b[t])>=2)
                t++;
            if((a2[t2]>=21||b2[t2]>=21)&&abs(a2[t2]-b2[t2])>=2)
                t2++;
        }
    }
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/fusiwei/p/11220482.html