Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
MAJSTOR - Majstor |
English | Vietnamese |
Rock-paper-scissors is a popular two-player game. In the game, each of the players uses their hand to show one of three symbols: rock, paper or scissors. If both players show the same symbol, the game is a tie. Otherwise, scissors beat paper, paper beats rock and rock beats scissors.
Sven has been studying the psychological intricacies of the game for years and has become a real master at the game, his friends not standing a chance against him in one-on-one games.
With the world championships around the corner, Sven is practicing his skills playing simultaneous games with N of his friends. One such game consists of R rounds. In each round, Sven and each of his friends show one of the three symbols.
When calculating the score, in each round, Sven's symbol is independently compared to each of his friends' symbols. Sven scores two points for every win and one point for every tie. Sven does not get points for losing.
Write a program that calculates Sven's total score, and also his largest possible score had he known in advance all the symbols his friends would show.
Input
The first line contains the integer R (1 ≤ R ≤ 50), the number of rounds played.
The second line contains a string of R letters 'S', 'P' or 'R'. The string represents symbols that Sven showed in each round. 'S' is for scissors, 'P' for paper, 'R' for rock.
The third line contains the integer N (1 ≤ N ≤ 50), the number of friends.
Each of the following N lines contains a string of R letters 'S', 'P' or 'R'. These are the symbols shown by each of the N friends in each of the R rounds.
Output
Output Sven's actual score on the first line.
Output his largest possible score on the second line, assuming his friends didn't change their symbols.
Example
Input 5 SSPPR 1 SSPPR Output 5 10
Input 5 SSPPR 2 PPRRS RRSSP Output 10 15
Input 4 SPRS 4 RPRP SRRR SSPR PSPS Output 12 21
Được gửi lên bởi: | Race with time |
Ngày: | 2009-02-17 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 1024B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET |
Nguồn bài: | COCI 2008/2009 - Croatian Regional |
hide comments
|
|||||
2017-09-14 12:09:56
ai có code hay cho tham khảo với ạ |
|||||
2014-03-18 17:25:06 Thcs Ðặng Chánh Kỷ
BÀI NÀY DỄ CHẾT THẬT |
|||||
2014-03-18 15:23:07 Lollipop
ths mấy bạn, co mãi chít cả màn hình. 1 đấm AC |
|||||
2014-03-17 17:28:02 Thanga2pbc
ĐM cùng 1 code 31 dòng k ac.thụt lại 29 mới ac |
|||||
2014-03-17 17:22:12 Nắng
code phải ngắn hơn 30 dòng @@ mất mịa hơn 30p @@@@@@@@@ |
|||||
2013-08-31 15:17:17 Bitagi97
độ dài mã nguồn ==' |
|||||
2013-06-11 04:29:53 Hồ Sỹ Thành
Sai test nào nữa đây trời @@ |
|||||
2011-10-07 17:45:53 Hoàng Hà
nhìn cái giới hạn mã nguồn mà ghét >.< |
|||||
2011-08-12 11:10:51 Noyethug
bài này đọc đề k cẩn thận die lun.........:| |
|||||
2011-07-16 10:03:30 St.VDQD
bài này mình code Pascal 809B |