# B - GOLF CROQUET

In golf croquet doubles, two teams of 2 play each other. Each player has their own ball which they hit when it is their turn. A turn comprises one hit of the ball.
There are 6 hoops which are each played twice, once in each direction, in a prescribed order.
A point is scored by the first team to “make” the current hoop. To make a hoop, one of the team’s balls must be knocked through the current hoop in the right direction. The first team to score 7 points wins. If the game reaches 6-6, a final deciding hoop is played. Note that a team cannot score more than 7 points – the game ends as soon as the 7 th hoop is won.
The balls are played in a fixed order: blue, red, black (blue’s partner) then yellow (red’s partner). We can record the progress of a match by recording the outcome of each shot. The code we are using is:
S a standard shot that does not make a hoop H a shot that makes a hoop for the team who played the shot D a shot that makes 2 hoops for the team who played the shot – an extremely unlikely scenario but it can happen! A team on 6 points will only score the first of the two hoops, of
course.
O a shot that makes a hoop for an opponent’s ball!
The last one is almost certainly an accident, but it happens far more times than players like!

The input represents part or all of a single game of golf croquet. The first two lines each contain the name of a team, each consisting of one or more words. The name will be no more than 30 characters long. The first named team play blue and black. The third line is a single integer, S, which tells how many strokes are recorded, for a game that has started but which may not yet be completed. (0 < S <= 255)
The fourth line contains S upper case letter characters, each being one of the 4 characters defined above (S, H, D or O). Blue always plays the first shot followed in turn by red, black and yellow.

Output a single line of text with the current score in the form
team1name x team2name y.
Follow this by a space then one of:
teamname has won.
teamname is winning.
All square.

Team Sally
The dragons
26
SSSSHSSSSSHSSSSSHSSSSSSHSS

Team Sally 3 The dragons 1. Team Sally is winning.

has won:在字符串全部模拟之前就已经分出胜负

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

char s1[265], s2[265];
int len;
char str[1005];

int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);

gets(s1), gets(s2);
scanf("%d %s", &len, str);
int sc1 = 0, sc2 = 0, i;
for (i = 0; i < len; i++){
if(str[i] == 'S') continue;
if(str[i] == 'H'){
if(i & 1) sc2++;
else sc1++;
if(sc2 == 7 || sc1 == 7) break;
}else if(str[i] == 'O'){
if(i & 1) sc1++;
else sc2++;
if(sc2 == 7 || sc1 == 7) break;
}else{
if(i & 1){
sc2 += 2;
if(sc2 >= 7) sc2 = 7;
if(sc2 == 7) break;
}else{
sc1 += 2;
if(sc1 >= 7) sc1 = 7;
if(sc1 == 7) break;
}
}
}
printf("%s %d %s %d.", s1, sc1, s2, sc2);
if(i >= len){
if(sc1 > sc2) printf(" %s is winning.\n", s1);
else if(sc1 < sc2) printf(" %s is winning.\n", s2);
else printf(" All square.\n");
}else{
if(sc1 > sc2) printf(" %s has won.\n", s1);
else if(sc1 < sc2) printf(" %s has won.\n", s2);
else printf(" All square.\n");
}

return 0;
}