2979 - I2P(II)2024_Yang_hw3 Scoreboard

Time

2024/03/29 15:20:00 2024/04/12 13:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13485 String Calculator(class)
13862 Pineapple senpai’s family
14273 Gomoku Battle

13485 - String Calculator(class)   

Description

In this problem, you need to finish a string calculator.

The calculator has three string operators:

  • a + b: Concatenate the string b after the string a.
  • a - b: If string b has appeared in string a, delete the first appearance of b in a, otherwise the result is "error".
  • a / b: The number of occurrences of string b in string a.

Note: You are suggested to practice the usage of C++ string class (https://www.cplusplus.com/reference/string/string/).

  • function std::operator+: Concatenate strings (https://www.cplusplus.com/reference/string/string/operator+/)
  • public member function std::string::find: Find content in string (https://www.cplusplus.com/reference/string/string/find/)
  • public member function std::string::substr: Generate substring (https://www.cplusplus.com/reference/string/string/substr/)
  • etc.

Input

The first line contains an integer N

The following N lines, each line contains two string a b.

 

testcases:

(6/6) 1 <= N <= 100, 1 <= |a|, |b| <= 100

Output

The output contains lines.

For each a b, output ((a - b)+b)/b

Sample Input  Download

Sample Output  Download

Partial Judge Code

13485.cpp

Partial Judge Header

13485.h

Tags




Discuss




13862 - Pineapple senpai’s family   

Description

Katex

Pineapple Senpai is introducing his family to you.

Each member of his family has some strong relatives such as ParentA, ParentB, Mate, and Child.

And there would be a narrator in the family, who is responsible to introduce the family to you.

Initially, the narrator is Pineapple Senpai himself, and the narrator would introduce his relative's attributes such as gender, age, name, and personality.

Each relative is selected by a strong-relative-chain. For example, if the strong-relative-chain is "ParentA Child", it means that the relative is the narrator's ParentA's Child(which is the narrator itself).

So there are three types of queries you need to proceed

  • 1 strong-relative-chain
  • this type of query asks you to change the narrator to the current narrator's relative, which is selected by the strong-relative-chain.
  • 2 strong-relative-chain attribute-modification
  • this type of query asks you to change the attribute of the current narrator's relative, which is selected by the strong-relative-chain. the attribute-modification's would specify the name of the attribute, and the value to be changed. There are four types of attributes: "Gender: ENUM, Age: INT, Name: STRING, Personality: STRING".
  • 3
  • this type of query asks you to print the info of the current narrator, you should call the built-in function directly.

Note that the first time every relative is introduced to you, there may be some information that is not directly revealed by the narrator but you should notice.

When a Child is first introduced to you, at least one of its parent is introduced early, which should be the Child's ParentA.

A Child's ParentA and ParentB should always be Mate to each other.

If B is A's Mate, A's Child would be B's Child, too.

Each time a perstonality is described, you should concatenate the new described personality behind the original personalities spacing by a single space character.

    Constraints

  • \(1 \leq Q \leq 1000\)
  • \(1 \leq len(strong-relative-chain) \leq 1000\)
  • \(1 \leq len(attribute-chain) \leq 200\)

This is a Partial judge Problem.

All you need to do is to implement the getRelative and describe function.

For the getRelative function, you should return the pointer to the relative that is selected by the strong-relative-chain

For the describe function, you should modify the corresponding attribute of the relative selected by the strong-relative-chain

Note that you should compile the solution with C++17.

Input

Katex First line is \(Q\), so there are \(Q\) queries. Next \(Q\) lines, each line contains a query.

Output

Katex Output the info of the narrator for each type 3 query.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13862.cpp

Partial Judge Header

13862.h


Discuss




14273 - Gomoku Battle   

Description

This afternoon, Doraemon and DebugCatCapoo have a Gomoku battle.
However, they've slightly altered the rules since Capoo often ends up secretly eating the pieces Doraemon puts down...

In their version of Gomoku, Doraemon goes first. On his turn, he can put his pieces on two empty spots. When it's Capoo's turn, he puts his piece on one empty spot, and then picks a spot with a piece on it to remove (eat) that piece.

To simplify the rules, their game's goal is to form an unbroken line of 5+ pieces of their own color either horizontally or vertically, and the lines going diagonally don't count. If someone tries to play out of turn, that move is ignored. It's guaranteed that both players will not place pieces on occupied spaces or outside the board, and Capoo will not attempt to remove (eat) a piece from an empty space or outside the board.

This is a partial judge problem. Write a program to determine the winner of their Gomoku game. Please review the provided code and implement the section marked TODO in function.h.

 

Input

This problem consists of several test cases.

Each test case begins with a line containing an integer 5 ≤ N ≤ 10, which indicates the game is played on an N×N board. The lines that follow are formatted as <Doraemon/DebugCatCapoo> <location> <location>, where each location is a two-digit string, indicating the action taken by the player. There are no more than 100 actions taken by the two players for each round of the game.

For example, the actions taken by the players are represented as follows:

  • Doraemon 35 03 means Doraemon places pieces on row 3, column 5, and row 0, column 3.
  • DebugCatCapoo 32 04 means DebugCatCapoo places a piece on row 3, column 2, and removes a piece from row 0, column 4.

Please note that sometimes a player may take action even when it's not their turn. For example, in the second action of round #1 in the sample input, it's DebugCatCapoo's turn, but Doraemon takes an action. In such cases, the move made by Doraemon will be ignored until DebugCatCapoo performs its move. You need to verify the value of GomokuGame::turn within the GomokuGame::place() and GomokuGame::remove(). If it's not the correct player's turn, return false to abort the action.

A string of - - - marks the end of a test case and the conclusion of the game.

 

Output

The winner of the game and the status of the board will be outputted.
(O -> Doraemon, X -> DebugCatCapoo, this part is already implemented)

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

14273.cpp

Partial Judge Header

14273.h

Tags




Discuss