codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

106A.md (1835B)


      1 Source: https://codeforces.com/problemset/problem/106/A
      2 
      3 A. Card Game
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 There is a card game called "Durak", which means "Fool" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly — you can find them later yourselves if you want.
     22 
     23 To play durak you need a pack of 36 cards. Each card has a suit ("S", "H", "D" and "C") and a rank (in the increasing order "6", "7", "8", "9", "T", "J", "Q", "K" and "A"). At the beginning of the game one suit is arbitrarily chosen as trump.
     24 
     25 The players move like that: one player puts one or several of his cards on the table and the other one should beat each of them with his cards.
     26 
     27 A card beats another one if both cards have similar suits and the first card has a higher rank then the second one. Besides, a trump card can beat any non-trump card whatever the cards’ ranks are. In all other cases you can not beat the second card with the first one.
     28 
     29 You are given the trump suit and two different cards. Determine whether the first one beats the second one or not.
     30 
     31 Input
     32 
     33 The first line contains the tramp suit. It is "S", "H", "D" or "C".
     34 
     35 The second line contains the description of the two different cards. Each card is described by one word consisting of two symbols. The first symbol stands for the rank ("6", "7", "8", "9", "T", "J", "Q", "K" and "A"), and the second one stands for the suit ("S", "H", "D" and "C").
     36 
     37 Output
     38 
     39 Print "YES" (without the quotes) if the first cards beats the second one. Otherwise, print "NO" (also without the quotes).
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 H  
     47 QH 9S
     48 ```
     49 
     50 Output
     51 
     52 ```
     53 YES
     54 ```
     55 
     56 Input
     57 
     58 ```
     59 S  
     60 8D 6D
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 YES
     67 ```
     68 
     69 Input
     70 
     71 ```
     72 C  
     73 7H AS
     74 ```
     75 
     76 Output
     77 
     78 ```
     79 NO
     80 ```