report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Matrix Zigzag - FlandreOJ: Flandre Online Judge

Matrix Zigzag

Time limit: 1000 ms
Memory limit: 256 MB
Given an $n \times m$ matrix, print the elements in diagonal zigzag order, starting from position $(1,1)$ and ending at position $(n,m)$. For example:
### Input - The first line contains two integers, $n$ and $m$. - The next $n$ lines each contain $m$ integers representing the matrix. ### Output - Print $n$ integers as the answer. ### Constraints - $1 \le n, m \le 50$. - $1 \le A_i \le 100$ ### Example Input: ``` 3 3 1 2 3 4 5 6 7 8 9 ``` Output: ``` 1 2 4 7 5 3 6 8 9 ```
Two dimensional array
Pascal's triangle
Column sum
Appearance
Diagonal sum
Point coverage
Swap operation
Spiral matrix
Word search
Matrix rotation
Matrix Zigzag
Topic
Basic
Rating 800
Solution (0) Solution