13018 - Diagonally sorting   

Description

Given a NxM array, please sort each diagonal line in ascending order from top-left to bottom-right.

 

For example, given 4x4 array, you should sort these diagonal lines:

This problem is partial judge, you need to implement the function:

// Sort each diagonal line of arr (which size is row x col)

void array2d_sort(int row, int col, long long arr[][500]);

 

Input

The first line contains two integers, N, M. 

The next N lines contain the array, each element in the array is separated by a space.

1 ≤ N, M ≤ 500

-1010 ≤ element in the array ≤ 1010

 

Output

Output the diagonally sorted array, with each element in the array separated by a space, and print out a newline after each row.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13018.c

Partial Judge Header

13018.h

Tags




Discuss