|Online MIPT programming contest||РУССКИЙ|
Time limit = 5Equilateral triangle is given. Each side divided to N equal parts by N-1 points, each of which connected with two points on other sides, by lines parallel to sides of the triangle. So the triangle is divided to N2 equilateral triangles. Numbers from 1 to N2 are written on this small triangles and on each of common sides of small triangles, written sign '<' (less) or '>' (more), which says that number in one triangle is less or more then number in another. You are to find one of possible placements of numbers for given signs.
Input First line of input contains one integer: N (2<=N<=50). After that (N-1)*2 lines contains signs on sides of triangles. In line number n*2+1 there are given n+1 signs on horizontal line between rows number n+1 and n+2, '<' means that number on the top less then number on the bottom and vice versa. Line number n*2+2 contains (n+1)*2 signs on slanting sides of triangles in row number n+2, '<' means that left number is less than right number and vice versa.
Output If it is impossible to place the numbers output contains "0", otherwise first line of output contains "1" and N following lines contains numbers separated by space. In n'th line there are n*2-1 numbers form n'th row.
3 > <> <> <<><
1 9 1 7 4 2 5 8 3 6
10 may 2003
© acm.mipt DevGroup
The page was generated in 190ms