2903 - I2P(I)2023_Yang_hw9 Scoreboard

Time

2023/11/28 22:00:00 2023/12/05 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11269 Text Editor
14114 Most Valuable Sentence

11269 - Text Editor   

Description

In this problem we simulate a simple text editor. Given a series of keyboard input, output the final text content.
The text editing rules are defined as following:
1. Normal alphabetical input and whitespace input (abcdefg…. and ‘ ‘) directly write  after the cursor of the text content.
And four special commands started with a backslash(/) character
2. The backspace command which deletes a letter before the cursor (/backspace)
3. The newline command which creates a new line after the cursor (/newline)
4. The two navigating commands which move the cursor (/left /right)

The size of the text content is fixed to 500 characters, and the text content of testcases will not exceed 500 characters when simulating.

Use fgets(). (https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fgets-fgetws?view=msvc-170)

Hint:

#include <stdio.h>

#define MAX_SIZE 500

char content[MAX_SIZE];
char input[MAX_SIZE];

int main()
{

    fgets(input, MAX_SIZE, stdin);

    /* your code here */

    printf("%s", content);

    return 0;
}

Input

The keyboard input sequence.
There is always a valid command(/backspace /newline /left /right) right after the backslash character.
There is no newline character at the end

Output

The final text content.

Sample Input  Download

Sample Output  Download

Tags




Discuss




14114 - Most Valuable Sentence   

Description

A group of N people are debating and unable to decide whom to believe. Therefore, they devised a method: collectively determining a keyword. Whoever mentions the keyword the most in their sentences will be considered the most valuable.

Given N, a keyword, N people, and N sentences, please output the person to be trusted along with the sentence they uttered. In case the most valuable sentence isn't unique, the first person who speaks it will be considered as delivering the most valuable statement.

Note that a keyword will only be counted when it appears as a single word. For example, if the keyword is 'ac', instances like 'ac' within the word 'teach' won't be considered. However, if 'ac' is preceded or followed by punctuation marks, those instances will be counted. Also, the keyword is case-insensitive, which means 'Ac', 'AC', 'ac', 'aC' will all be counted.

 

Hints:

1. Use strtok(). (https://cplusplus.com/reference/cstring/strtok/)

2. Use fgets(). (https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fgets-fgetws?view=msvc-170)

Input

The first line contains an integer N and a keyword.

The following N line would be in this format:

<name>:<sentence>

 

len(keyword) <= 1000, N <= 1000, len(namei + sentencei) <= 100000

keyword is only composed by english letters.

<name> is composed by english letters and spaces.

<sentence> is composed by english letters, spaces, and ",.?!" these four punctuation marks.

Output

If the k-th person delivered the most valuable sentence, please output like this:

<namek>: <sentencek>

There is a space after ':' and a '\n' in the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss