2457 - I2P(I)2021_Yang_lab12 Scoreboard

Time

2021/12/28 18:30:00 2021/12/28 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13064 Young People won't Say Wood
12109 Text Editor 2

13064 - Young People won't Say Wood   

Description

According to Master Ma, young people will not say "wood".   The more times a person says "wood", the more likely that person is old.  Master Ma wants to warn the young people.  He downloads posts from forums, analyzes their comments, and determines the user's age using the following formula:

 

In the forum, every sentence ends with a period. Master Ma uses the number of periods to count the sentences.

He soon finds that besides "wood", sometimes young people uses "vv" instead of "w", "0" instead of "o", "cl" (English alphabets, not numbers) instead of "d" when spelling "wood". For example, "vvood", "w0od", "vv00cl" are alias of "wood". More formally, any word that starts with "w" or "vv", followed by a combination of "0" and "o" with length 2, and ended with "cl" or "d" are considered to be equal to "wood".

Some young people also embeds "wood" (or words equal to "wood") in longer words. Master Ma identifies them as well. For example, the word "woody" and "xxxwoodxxxw00dxx" is identified because "wood" (or words equal to "wood") is embedded in it.

(Figure: The blue highlighted parts are the "wood" identified by Master Ma. The other parts are examples that are not equal to "wood".)

Given a post downloaded by Master Ma. Please help Master Ma to calculate the age of the users since he needs some time to recover.

Maybe useful hints

You may need to use fgets, strtokstrstr,  or whatever string related function. The reference to the functions are provided in this link.

Some explanation on Sample IO

User with id 0 wrote three sentences: "Ha.", "Ha.", and "Ha.". Zero of the sentences include "wood". Therefore output 0 3 in the 0-th line.

User with id 2 wrote two sentences among all his comments. Two of the sentences include "wood". Therefore output 2 2 in the 2-nd line.

User with id 9 wrote two sentences. Only one sentence include "wood". Therefore output 1 2 in the 9-th line.

Input

The are several lines in a post, ended with EOF (end of file).

Each line is in the following format: "<user id>":"<comment of user>", where

  • <user id> is an non-negative integer less than 10, i.e. 0-9

  • <comment of user> consists of lower-case alphabets a-z, numbers 0-9, whitespace , comma ,, and period .; the comment may contain more than one sentence and is guaranteed to end with a period.

Technical Restriction

  • There are at most 25 lines.

  • Length of each line in the input file is at most 1000.

Output

Please output 10 lines, in the i-th line, please output the followings separated with space:

  • number of sentences including "wood" (or strings equal to "wood") in all comments of the user with id i

  • number of sentences in all comments of the user with id i

If a user has no comment in the post, please output 0 0.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12109 - Text Editor 2   

Description

In this problem we simulate a simple text editor. Given two lines of keyboard input texts and commands, output the final text content.

 

The text editing rules are defined as following:

1.

Normal alphabetical input and whitespace input (abcdefg…. and ‘ ‘) in the first line.

And a series of two special commands started with a backslash(/) character in the second line.

2.

The backspace command which deletes a letter before the cursor (/b)

3.

The navigating command which move the cursor to the right(/r)

4.

The cursor is at the beginning of the text initially.

 

For example, for the following input: 

The quick brown fox jumps over the lazy dog
/b/r/r/r/b

You should first store the "The quick brown fox jumps over the lazy dog" in the input char array and set cursor=0.

Then you can simulate the operation of the text editor.

 

The size of the text content is less than or equal to 500 characters, and there will be less than or equal to 500 commands when simulating.

 

char *fgets( char *str, int numChars, FILE *stream );

The C library fgets function reads a string from the input stream argument and stores it in strfgets reads characters from the current stream position to and including the first newline character, to the end of the stream, or until the number of characters read is equal to numChars - 1, whichever comes first. The result stored in str is appended with a null character. The newline character, if read, is included in the string.

 

Hint:

#include <stdio.h>

#define MAX_SIZE 1005


char content[MAX_SIZE];

char input[MAX_SIZE];

char command[MAX_SIZE];


int main()

{


    fgets(input, MAX_SIZE, stdin);

    fgets(command, MAX_SIZE, stdin);


    /* your code here */


    printf("%s", content);


    return 0;

}

Input

The first line is the text content which should be edited.

The second line is the commands.

There is always a valid command(/b /r) right after the backslash character.

 

Output

The final text content, and there should be no '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss