RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00478

Spirale

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

1 \(s / 64\) \(MB / 80\) points

Little Stjepan often likes to go out with his friends and have fun in a popular nightclub in

Zagreb. However, Stjepan sometimes drinks too much soda and gets light headed from all

the sugar. Last night was an example of this, which is why Stjepan had the same image in

his mind the whole time. It was a scribble of number spirals of some sort. Since he can’t

quite remember what the image looked like, but can describe it, he is asking you to

reconstruct it for him.

Stjepan recalls that the image was of the shape of a table consisting of numbers written in \(N\)

rows and \(M\) columns. Also, he recalls that there were \(K\) spirals in that table. For each spiral,

the starting position is known, as well as the direction it’s moving in, which can be clockwise

and count\(er-cl\)ockwise. An example is shown in the images below. The spirals created

Stjepan’s image in exactly 10 {100}{ } steps in the following way:
1.
Initially, the table is empty, and each spiral is in its own starting position.
2.
In each following step, each spiral moves to its next position. It is possible that, at

times, the spirals leave the boundaries of the table, but also to return within it.
3.
After exactly 10 ^{100} steps, for each field in the table, the final value is the value of the

earliest step in which one of the spirals touched that field.

3
2
9
4
1
8
5
6
7

Image 1: a spiral moving count\(er-cl\)ockwise

9
2
3
8
1
4
7
6
5

Image 2: a spiral moving clockwise

제약

In test cases worth 50% of total points, it will hold: \(N\) = \(M\) i \(K\) =1 and \(X\) {i}{ }= \(Y\) {i}{ }=⌊
⌋, i.e. \(X\) {i}{ } and \(Y\) _{i}
2
\(N+1\)

will be equal to the integer division of \(N\) +1 with 2.

입력 형식

The first line of input contains positive integers \(N\) , \(M\) (1 ≤ \(N\) , \(M\) ≤ 50) and \(K\) (1 ≤ \(K\)\(N\) * \(M\) ).
Each of the following \(K\) lines contains three positive integers \(X\) {i}{ }, \(Y\) {i} and \(T\) (1 ≤ \(X\)\(N\) , 1 ≤ \(Y\)

\(M\) , 0 ≤ \(T \le 1\)), the starting position of the \(i\) ^{th} spiral and its direction (\(0 - cl\)ockwise, 1 -

count\(er-cl\)ockwise). No two spirals will begin in the same field.

출력 형식

You must output \(N\) lines with \(M\) numbers, representing the table after each spiral makes

10 {100}{ } steps.

예제 1
입력
3 3 1
2 2 0
출력
9 2 3
8 1 4
7 6 5
예제 2
입력
3 3 1
2 2 1
출력
3 2 9
4 1 8
5 6 7
예제 3
입력
3 3 2
1 1 0
1 2 0
출력
1 1 4
6 5 5
19 18 17
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2017/2018 Contest 5

평가 및 의견

Spirale

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Spirale

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8