1281 - I2P(I)2017_Course_exemption Scoreboard

Time

2017/09/25 15:40:00 2017/09/25 18:10:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10900 Transpose of A Matrix
10957 Mouse Maze
11247 Sorting
11287 delete linked list
11480 Parentheses Matching

10900 - Transpose of A Matrix   

Description

Given a matrix A (you can consider it as a 2-D array), print out transpose of A.

Note: Try to use dynamic memory management to finish this problem.

main.c

#include <stdio.h>

#include "function.h"


int main(void) {


  int **mat;

  int m, n, i;


  scanf("%d %d", &m, &n);


  mat = allocateMat(m, n);

  readInput(mat, m, n);

  printResult(mat, m, n);


  // Be sure to release acquired memory space

  for(i=0; i<m; i++)
    free(mat[i]);
  free(mat);

  return 0;

}

function.h

#ifndef FUNCTION_H

#define FUNCTION_H


int** allocateMat(int, int);

void readInput(int**, int, int);

void printResult(int**, int, int);


#endif

Input

First line has two integers, indicates A is M rows by N columns. Next M lines are the content of A, each line has N integers.

Output

N lines, each line contains M integers. Values are separated by a blank. There’s a blank and a newline at the end of each line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

10900.c

Partial Judge Header

10900.h

Tags




Discuss




10957 - Mouse Maze   

Description

Write a program that simulates a mouse in a maze. The program must count the steps taken by the mouse from the starting point to the final point.

The maze type is shown in following figure:

S$###
$$#$$
$$$##
##$$F

it consists of S (starting point), #(walls), $(road) and F (final point).

In above case, it needs 7 steps from S to F as following figure,

S$###
$$#$$
$$$##
##$$F

and the mouse can move in the four directions: up, down, left, right. There may be more than one way to reach final point, the program only need to print the least steps.

If there is no way from S to F, then print -1.

Input

The first line has an integer N(1<=N<=1000), which means the number of test cases.

For each case, the first line has two integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of rows and columns of the maze, respectively. The total number of elements in the maze is thus R x C.

The following R lines, each containing C characters, specify the elements of the maze.

Output

Print out the least steps for each case, and there is a new line character at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11247 - Sorting   

Description

This is a partial judge problem , your mission is to read the partial judge code given below

and implement 2 functions: 

    1.void  sort(int a[],int len) 

     --> Sort the disorder integer array in ascending order. ※len = the length of the integer array

    2. void show_the_array(int a[],int len)

      --> Print out the sorted array , and follow the output format ※len = the length of the integer array

Please submit the implementation of these 2 function to NTHU OJ and choose C compiler . 

You have to use this partial judge code to implement the 2 function:

#include<stdio.h>
#include<stdlib.h>
void sort(int a[] , int len);
void show_the_array(int a[] , int len);

int main(void){
    int i,N;
    scanf("%d",&N);
    int *S = malloc(sizeof(int)*N);
    for(i=0;i<N;i++)scanf("%d",S+i);
    sort(S,N);
    show_the_array(S,N);
    return 0;
}

 

Input

The 1st line contains an integer N which indicate the length of the integer array.

The 2nd line contains N integers which are the elements in that array.

Output

Print out the sorted integer array in ascending order.

Note that :

1.There is a "space" between any 2 integers.

2.There is no need to add "\n" at the end of output.

3.There is no need to add "space" at the end of output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11247.c

Partial Judge Header

11247.h

Tags




Discuss




11287 - delete linked list   

Description

This problem will give you a sequence of positive integers.  Use this sequence to create a linked list to store those integers.  Next, the problem will give you another sequence of positive integers, p0, p1,…pk-1.  Delete the nodes that the data is equal to one of p0, p1, …pk-1 of the linked list. If the node is not existing,do nothing.  And show the final results.

 

The framework of the program is provided.

  1. Create a linked list from the input  (createList)
  2. while there are still some data pi
  3. read in pi
  4. delete node that data is equal to pi  (deleteNode)
  5. print the remaining list (printList)
  6. free the list (freeList)

You will be provided with main.c and function.h. main.c contains the implementation of function printList, and freeList, and function.h contains the definition of node and the interface of createList() and deleteNode(&head, pi).  You only need to implement createList() and deleteNode(&head, pi) in function.c, in which head is the head of the linked list, and pi is the data of the node to be deleted.

 

For OJ submission, you only need to submit your createList and deleteNode implementation to the submission block. (Choose c compiler) 

Input

The input contains 2 sequences of positive integers.  The first sequence is to create a linked list of integers, and the second sequence is the nodes to be deleted.  Each sequence is ended by -1. 

Output

The output contains the sequence of resulting linklist.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11287.c

Partial Judge Header

11287.h

Tags




Discuss




11480 - Parentheses Matching   

Description

A string is said to be valid if it matches one of the following rules:

 (1) The string is an empty string.

 (2) If a string S is valid, then {S}, [S], (S) and <S> are valid.

 (3) If strings S1 and S2 are both valid, then S1S2 is valid.

Given a string consisting of parentheses, determine if it is a valid string.

Input

The first line of the input contains an integer N (N ≤ 10000) denoting the number of test cases followed by. Each of the next N lines corresponds to a test case, which contains a string consisting of parentheses, and the maximum string length will be no more than 1000. Note that an empty string (a line which contains the newline character only) may be contained in the input and it should be considered as a valid string according to rule (1).

 

Case 1 : N≤50

Case 2 : N≤100

Case 3 : N≤1000

Case 4 : N≤10000

Output

For each test case, print “Case i:” and then “Yes” or “No” to indicate that the string is valid or not, separated by a space character. i is the test case number starting from 1.

Sample Input  Download

Sample Output  Download

Tags




Discuss