Zig-zag P71711


Statement
 

pdf   zip

html

Write a program that reads several matrices of integer numbers, and that for each one tells whether the result of traversing it in zig-zags is a strictly increasing sequence. We must start at the top-left position, go down the first column, up the second column, down the third column, and so on.

Input

Input consists of several matrices, each with the number of rows r ≥ 1 and the number of columns c ≥ 1, followed by r rows with c integer numbers each.

Output

For every matrix, print its number followed by either “yes” o “no”, depending on whether the zig-zag traversal of the matrix generates a strictly increasing sequence or not.

Public test cases
  • Input

    3 4
    10 15 36 41
    11 14 37 40
    12 13 38 39
    
    3 2
    10 11
    12 13
    14 15
    
    2 2
    5 7
    6 6
    
    2 3
    1 4 5
    2 3 5
    
    1 1
    -3
    
    1 3
    4 6 8
    
    2 1
    100
    200
    

    Output

    matriu 1: yes
    matriu 2: no
    matriu 3: no
    matriu 4: no
    matriu 5: yes
    matriu 6: yes
    matriu 7: yes
    
  • Information
    Author
    Professors de P1
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++