2603 - I2P(I)2022_Yang_hw6 Scoreboard

Time

2022/10/18 21:00:00 2022/10/25 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12434 Bacteria Widespread
13309 How much is the string worth 2

12434 - Bacteria Widespread   

Description

Hey, can I say somthing amazing?  Bacteria touched the air for some reason and begin to widespread in the classroom. The bacteria turned out to be Firmicutes (some kind of bacteria). The classroom can be viewed as a 2D grid map with size R x C. Walls in classroom are denoted as #, clean areas not polluted by Firmicutes are denoted as C, and places where there exist Firmicutes are denoted as F. The classroom is guaranteed to be surrounded by walls. For example a classroom of size 7 x 8 with some area polluted may look like this :

 ########
 #CCC#CC#
 #CFC####
 #CCCCCC#
 #CC#####
 #FCCCCC#
 ########

Firmicutes reproduces rapidly. Initially, some areas in the classroom are polluted by Firmicutes. For every second, if an area is polluted by Firmicutes, the Firmicutes on this area will reproduce themselves and spread to neighboring clean areas. Here, we define neighboring areas of area (r, c) are (r+1, c), (r-1, c), (r, c+1), and (r, c-1). Note that Firmicutes cannot spread onto walls, which means that even if a wall is neighbor to some polluted area, the wall will not be polluted. The following example is a classroom from t = 0 ~ 2 seconds.

Initially, t=0. Some areas are polluted.

 ########
 #CCC#CC#
 #CFC####
 #CCCCCC#
 #CC#####
 #FCCCCC#
 ########

When t=1,

 ########
 #CFC#CC#
 #FFF####
 #CFCCCC#
 #FC#####
 #FFCCCC#
 ########

When t=2,

 ########
 #FFF#CC#
 #FFF####
 #FFFCCC#
 #FF#####
 #FFFCCC#
 ########

Given how the class looks like initially (when t=0) and a time T, please output how the classroom looks like when t=T.

Maybe useful hint

(Feel free to skip this part if you have your own idea on how to solve this problem :) )

1. Use an array or arrays to record how the classroom looks like in the 0-th second, 1-st second, ..., T-th second, respectively.

2. A straightforward implementation:
 
for each second
{
    Step 1: find & record  F 's locations in the classroom.
    Step 2: update the neighbors of each found  F  in Step 1 as required.
}

Input

The first line consist of three integers R, C, T, meaning the size of the classroom and a time.

For the following R lines, each line has C characters, being how the classroom looks like initially. Each character will be one of {#, C, F} and the classroom is surrounded by walls (#).

Technical Restrictions

  • 3 ≦ R, C ≦ 100

  • 0 ≦ T ≦ 100

  • The first test case is same as sample IO. It is suggest to use it to check whether your output format is valid.

Output

Please output how the classroom looks like in the T-th second (when t=T).

Sample Input  Download

Sample Output  Download

Tags




Discuss




13309 - How much is the string worth 2   

Description

In this problem, the first line of input contains a string C, we define C1 worth 1 coin, C2  worth 2 coins, C3 worth 3 coins ...., C26 worth 26 coins, other charactor worth 0 coin.
Now we have some lines of string (may contain spaces), you need to write a program to calculate how much each line is worth until S0 or end.

Hint:
0_ or _0 ( _ = space) worth 0, not the end of input

Input

The first line contains a string C, Ci worth i coins

The next lines, each line contains a string (may contain spaces)

Testcases:

(4/7) C = abcdefghijklmnopqrstuvwxyz, 0 <=  |S| <= 100, S  end

(1/7) C = abcdefghijklmnopqrstuvwxyz, 0 <=  |S| <= 100

(1/7) C = the permutaion of a ~ z, 0 <=  |S| <= 100S  end

(1/7) C = the permutaion of a ~ z, 0 <=  |S| <= 100

Output

Output the value of each line of string until S = 0 or end.

Sample Input  Download

Sample Output  Download

Tags




Discuss