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

Kocka

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

의견: 0

설명

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

I’m again in the cube!
I’m again in the cube!

While watching the kids’ playground in the early morning hours, the author of this task caught sight of

an interesting object: a cube made out of metal bars, composed of many un\(it-si\)zed cubes made out

of metal bars.

While observing the cube, an interesting problem came to his mind. Here follows the t\(wo-di\)mensional

version of the problem, since nobody likes problems involving 3D objects:

You’re given \(N\) × \(N\) matrix ( square for reference). Some of the fields in the square are blocked and

some are empty. The author was watching the square from each of its 4 sides. Firstly, he looked at

the square from its left side, and for each of its \(N\) rows he wrote how many empty field there were in

the row in front of the first blocked field he could see. If there were no blocked fields in a row, he

wrote down the numb\(er -1\). Then he repeated the same procedure looking at the square from its right,

top and bottom side, in that order.

By doing so, he wrote 4 \(N\) numbers in total, as he wrote \(N\) numbers for each side of the square.

However, unknown villains destroyed his square and the only thing left were the numbers he had

written down. The author of the task wonders if those numbers make any sense, i.e. if it is possible to

form a square for which the same sequence of numbers will be obtained by doing the described

procedure.

제약

In test cases worth 40% of total points, it will hold that \(N\) ≤ 1000.

입력 형식

The first line contains a positive integer \(N\) (1 ≤ \(N\) ≤ 100 000), dimension of the square.
The second line contains \(N\) integers \(L\) {i} (-1 ≤ \(L\) < \(N\) ), numbers obtained by watching the square from

its left side, in order from 1 {st}{ } to \(N\) {th}{ } row.
The second line contains \(N\) integers \(R\) {i} (-1 ≤ \(R\) < \(N\) ), numbers obtained by watching the square from

its right side, in order from 1st to \(N\) {th}{ } row.
The second line contains \(N\) integers \(U\) {i} (-1 ≤ \(U\) < \(N\) ), numbers obtained by watching the square from

its top side, in order from 1 {st}{ } to \(N\) {th}{ } column.
The second line contains N integers \(D\) {i} (-1 ≤ \(D\) < \(N\) ), numbers obtained by watching the square from

its bottom side, in order from 1 {st}{ } to \(N\) {th}{ } column.

출력 형식

If it is possible to from a square which satisfies the given conditions, print “DA” (Croatian for yes,
without quotation marks), otherwise print “NE” (Croatian for no).

예제 1
입력
3
-1 2 0
-1 0 1
2 2 1
0 0 1

3
-1 0 1
-1 2 1
-1 2 -1
1 0 -1
출력
output
DA

NE
설명

Clarification of the first test sample:

2
2
1

-1

-1
2

0
0

1

0
0
1

문제 정보

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

출처 COCI 2018/2019 Contest 2

평가 및 의견

Kocka

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

Log in to rate problems.

개별 의견

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

풀이 제출

Kocka

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