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

S3. The Geneva Confection

설명

In order to ensure peace and prosperity for future generations, the
United Nations is creating the world’s largest candy. The ingredients
must be taken in railway cars from the top of a mountain and poured into
Lake Geneva. The railway system goes steeply from the mountaintop down
to the lake, with a T-shaped branch in the middle as shown below.

Right now, each of the \(N\)
ingredients is in its own railway car. Each railway car is assigned a
positive integer from \(1\) to \(N\). The ingredients must be poured into
the lake in the order \(1,2,3,\ldots,N\) but the railway cars are
lined up in some random order. The difficulty is that, because of the
especially heavy gravity today, you can only move cars downhill to the
lake, or sideways on the branch line. Is it still possible to pour the
ingredients into the lake in the order \(1,2,3,\ldots,N\) ?

For example, if the cars were in the order \(2, 3, 1, 4\), we can slide these into the
lake in order as described below:

  • Slide car 4 out to the branch

  • Slide car 1 into the lake

  • Slide car 3 out to the branch

  • Slide car 2 into the lake

  • Slide car 3 from the branch into the lake

  • Slide car 4 from the branch into the lake

제약
입력 형식

The first line will contain the number \(T~(1 \leq T \leq 10)\) which is the number of different tests that will be
run. Each test has the form of an integer \(N~(1 \leq N \leq 100\ 000)\) on the first line of the test, followed by a
list of the \(N\) cars listed from top
to bottom. The cars will always use the numbers from 1 to \(N\) in some order.

출력 형식

For each test, output one line which will contain either
Y (for "yum") if the recipe can be completed,
and N otherwise.

예제 1
입력
2
4
2
3
1
4
4
4
1
3
2
출력
Y
N
문제 정보

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

출처 CCC 2014 Senior

평가 및 의견

S3. The Geneva Confection

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

Log in to rate problems.

개별 의견

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

풀이 제출

S3. The Geneva Confection

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