2604 - I2P(I)2022_Yang_mid1_practice Scoreboard

Time

2022/10/18 21:00:00 2022/11/01 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11628 Spiral
12022 prefix sum
12441 Palindrome
13573 String Operations 2
13633 Indentation
13637 Easy Gomoku Validator

11628 - Spiral   

Description

SunMoon likes spiral(漩渦). On the N*N’s space, he starts moving into the left top corner, (0,0), and walking right for totally N steps (including the first movement into (0,0)). He then walks down for N-1 steps, then walks left for N-2 steps and then walks up for N-3 steps… until no more steps are possible. When he walks across that space, he will draw '#' on the floor. The others that he doesn’t pass will be  ‘ ‘. Please tell SunMoon what the resulting spiral(漩渦) looks like.

 

Input

There is a positive number T(1 <= T <= 1000). It means that there are T numbers.

In next T lines, each line contains a positive number N(1 <= N <= 5000),which is the size of the space.

Output

Please show the resulting spiral(漩渦).

Note: The first step is to enter (0,0), and the second step is to enter (0,1)…and so on.

About the output format, please refer to sample output below, the download of sample output is not correct.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12022 - prefix sum   

Description

 

Given a series of numbers, e1, e2, e3, ..., eN.

With these numbers, we want to know what the sum is in some consecutive range.

In every testcase, you will be given M queries.

Each of them contains two integers which represent left bound (L) and right bound (R) respectively.

Your mission is to give the result of eL + eL+1 + ... + eR,

-

Hint 0 : If you get WA for testcase 1, sample input and output might help you.

Hint 1 : If you get TLE for next three testcases, you should think how to decrease some redundant operations for calculations. Try to store other useful information in the array, instead of sum up all the elements for every query! You may search for the problem's title: "prefix sum".

How to estimate the running time of your code?
A usual computer can run 109 basic operations (such as +, -, &, |) in 1 second. Although this depends on the judging server, this number serves as a good estimation for the running time of your code. Try to figure out how much operations your code needs to execute to finish all the computations (since not all operations in your code are basic operations, another estimate criterion is 108 operations (+, -, *, /, =, ...) in 1 second)!

 

Hint 2 : If you get MLE, you have to reduce the size of array you created and decide what exactly should be in the array.

 

Input

First line contains one integer N which is the size of elements.

Second line will have N integers representing all elements in the testcase.

Third line contains one integer M which is the number of queries.

For following M lines, each line contains exactly two integers that stand for left bound (L) and right bound (R) respectively.

 

It is guaranteed that:

1. 10 ≦ N ≦ 1,000,000

2. 0 ≦ ei ≦ 100,000, for 1 ≦ i ≦ N

3. L must be less than or equal to R, and R won't exceed the size of elements.

Output

For each query, just give the answer in one line.

Also, remember to print '\n' in the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12441 - Palindrome   

Description

Palindrome is a string that is identical to its reverse, like "level" or "aba".  Check whether a given string is a palindrome or not.

Input

The input consists of multiple lines. Each line contains a string. The length of each string is less than 100000.  The number of test case is less than 1000.

Output

For each test case, output "Yes" if it's a palindrome or "No" if it's not a palindrome in a line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




13573 - String Operations 2   

Description

Aftermath, a student in NTHU, is very good at programming. Today, as usual, she comes up with a programming problem but felt bored to solve it by herself(it’s too easy for her!). Thus, she left the problem to you, that is:

Given a string that consists of only lowercase Latin characters, there are Q operations to apply on this string.
There are two types of operations, with the following two forms:

  • 1 A B
  • 2 id C

For operation of type 1, you have to turn every A in the given string to B.
For operation of type 2, you have to set the idth character to C.

After the Q operations, you should print the resulting string in one line(remember to print a new line character).

  • Hint 1: Whenever there’s a operation of type 2, the operations before it won’t affect the final result of the idth character.
  • Hint 2: Should it be easier if we deal with the operations in reverse order?
  • Hint 3: I want to be as smart as Aftermath.

Input

The first line contains a string s, which consists of only lowercase Latin characters.

The second line contains a integer Q.

The next Q lines, each contains a operation.

Constraints

  • 1≤|s|≤106
  • 1≤Q≤105
  • 0≤id≤|s|-1
  • A,B,C ∈[a−z]

for testcases 1~3, 1≤|s|≤1000

for testcases 4~6, there’s no additional constraints.

Output

Print the resulting string in one line after applying the Q operations.

(remember to print a new line character)

Sample Input  Download

Sample Output  Download

Tags

LoseLightLight BBQ 完了完了



Discuss




13633 - Indentation   

Description

You're now in a bad mood since you quarreled with your best friend. 

Recently, your best friend keeps convince you that using semicolons for indentation is the best way to code in C. He claimed that semicolons are beautiful, so you'll be in a good mood if you put a lot of semicolons in your code. What's more, you'll never forget to add a semicolon at the end of the line anymore. You think that your friend is insane and you have a severe headache every time you read his code. 

Therefore, you decide to get rid of this terrible habit for your friend: now your friend is taking a nap, and you are going to open his computer, find his code files, and turn all of his code to space indentation.

Given lines of compilable C code. Currently, the code is indented by semicolons, and now you want to rewrite this code using spaces for indentation.

In other words, you are going to do the following operations:

  • For every single line, turned every prefix semicolon into spaces.
  • Add a semicolon at the end of every single line, except for the lines mentioned below: 
    • Header file included. e.g. #include <stdio.h>
    • A line that contains '{' at the very end of it.
    • A line that contains only semicolons and a single '}' at the end.

          It is guaranteed that there are no other situations that don't need a semicolon at the end of the line.

Input

Lines of compilable C code, terminated by EOF.

Output

The code using space for indentation.

Sample Input  Download

Sample Output  Download

Tags

FlyHighHigh



Discuss




13637 - Easy Gomoku Validator   

Description

Katex

Gomoku, also known as 五子棋, is a kind of board game with the following rules.

Players alternate turns to place a stone of their color on an empty intersection. Black plays first. The winner is the first player to form an unbroken chain of five stones horizontally, vertically, or diagonally. And the game will stop immediately if someone wins the game.

Today LSC and TSC, are playing Gomoku on a \(15x15\) board. Where LSC plays the black side, TSC plays the white side.

It is known that in LSC's \(i\)th turn, he'll place his black stones to the position \((x_{2i-1}, y_{2i-1})\). And in TSC's \(i\)th turn, he'll place his white stones to the position \((x_{2i}, y_{2i})\).

Now given the length of the array \(x\) and \(y\), please determine who wins the game and at what turn he satisfied the winning condition. Or suppose that no one wins, please print "There's no winner." in one line.

Note that all index used in this problem are 1-based.

Solution(click here to view the solution if you don't want to solve it yourself)

Input

Katex

The first line of the input contains \(1\) integer \(N\), the length of array \(x\) and \(y\).

The following \(N\) lines, each contains two intergers \(x_i, \space y_i\).

    Constraints

  • \(1 \le N \le 15*15\)
  • \(1 \le x_i, y_i \le 15\)
  • \((x_i, y_i) \neq (x_j, y_j) \forall i \neq j\)

Output

Katex

Print your answer in one line.

Suppose LSC wins at the \(i\)th step, you should print("LSC wins at the %dth step", i), it is similar if TSC wins.

Print "There's no winner." if there's no winner.

Sample Input  Download

Sample Output  Download

Tags

LoseLightLight



Discuss