1453 - CS I2P 2018 Lee Quiz3 Scoreboard

Time

2018/05/04 15:55:00 2018/05/04 17:15:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11199 Tower of Hanoi
11210 Interval Overlap: function

11199 - Tower of Hanoi   

Description

The Tower of Hanoi is a mathematical game or puzzle. It consists of 3 rods, and N disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:

  1. Only 1 disk can be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.
  3. No disk may be placed on top of a smaller disk.

In this problem, you are given 3 rods named rod 1, 2 and 3, with N disks in a stack onto rod 1. Your mission is to move all disks onto disk 2 in minimal steps without breaking the riles provided. You have to print all moves.

You only have to implement the function "hanoi()" to achive the goal. Here is the defination of hanoi():

void hanoi( int rod_N, int rod_A, int rod_B, int rod_C ) ;

rod_N is the number of disks to be move right now, while rod_A, _B, and _C denoted the rod ID, which should be 1, 2, or 3. The function is to "Move the top rod_N disks from rod_A to rod_B via rod_C", and our main() function will hanoi(N, 1, 2, 3) without printing anything.

 

Input

The input consists of only one positive integers, denoting there are N disks given. At most 8 disks may be given.

Output

For the input, print all required steps of moving. Each move should be printed as an one-lined message like "Move from rod 1 to rod 2.\n". Please replace the rod ID on your own.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11199.c

Partial Judge Header

11199.h

Tags




Discuss




11210 - Interval Overlap: function   

Description

In this problem, we define an interval [a..b] as a continuous one-dimensional area form number a to b.

You are asked to calculate the number of interval pairs that overlap each other among a set of given intervals.  All intervals are located in a number line, and all their endpoints are integers.

This problem involves three parts:

  1. 11210.c: the source file containing the main function which calls isIntersec().
  2. 11210.h: the header file which defines isIntersec() and its prototype.
  3. Your answer as a C source file, in which you should implement the isIntersec() function, and the function only.

Input

The first line contains one number N, where 2 <= N <= 256, standing for the number of given intervals.

Each of the following N lines describes an interval and has 2 integers separated by space, representing

  1. the coordinate of the left vertex
  2. the coordinate of the right vertex

For each interval, you may assume the coordinate of the left vertex is smaller than the one of the right vertex.

Notice that each of the 2 numbers is representable by an int type in C language.

Output

The output should contain only one number, representing the number of interval pairs that intersect to each other.

Notice that if the overlapping part is of zero length, then the pair should NOT count.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11210.c

Partial Judge Header

11210.h

Tags




Discuss