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

Superpozicija

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

의견: 0

설명

1 sekun\(da / 512\) M\(iB / 110\) points
Wor\(ld-re\)nowned physicist Juraj has recently discovered a new kind of elementary particle – a parenthesision.
A parenthesision can have either an open ’(’ or ’)’ closed configuration. Using his homemade particle
accelerator, Juraj has created \(t\) sequences of superpositions of \(n\) parenthesisions. In each of the \(t\) sequences
there are \(n\) parenthesisions in a superposition between two different positions positions and (not necessarily
different) configurations. If the sequence is observed, the wave function of parenthesisions collapses and
each of them ends up in one of it’s possible positions and configurations. Juraj wants to know if it is
possible that the parenthesisions collapse into a valid sequence of parenthesis?
Juraj M. PhD knows that the quantum physics of these revolutionary and completely scientifically founded
particles are way over the head of an average COCI contestant, so he provided a formal task statement:
You are given \(t\) sequences of 2\(n\) open and closed parenthesis. Each of the parenthesis is a member of
exactly one pair of parenthesis. Two parenthesis within a pair can be different, both open, or both closed.
Juraj wants to know if it is possible to chose a single parenthesis from each of the pairs such that the
chosen parentheses form a valid sequence of parentheses. Furthermore, if this is possible he asks you to
print which parentheses he should chose to get a valid sequence. A sequence of parentheses is valid if it is
empty or it can be written as (A) or AB where A and B are arbitrary valid sequences of parentheses.

제약

Subtask 1 (10 points): \(1 \le n \le 10\)

Subtask 2 (10 points): \(z\)[\(a@@RISE_MATH_BLOCK_0@@i\)] for all \(i = 1\), 2, . . . n.

Subtask 3 (20 points): \(b@@RISE_MATH_BLOCK_1@@i + 1\) for all \(i = 1\), 2, . . . n.

Subtask 4 (70 points): No additional constraints. 1 sekun\(da / 512\) M\(iB / 110\) points

입력 형식

The first line contains an integer \(t\) (\(1 \le t \le 100\,000\)), number of parentheses sequences. \(t\) sequence
descriptions follow.
The first line of sequence description contains an integer \(n\) (\(1 \le n \le 100\,000\)), number of pairs of
parentheses in the sequence.
The second line contains \(z\), a string of length 2\(n\). \(z\) contains exclusively characters ( and ).
The following \(n\) lines of sequence description contain two integers \(a@@RISE_MATH_BLOCK_0@@i\) (\(1 \le a@@RISE_MATH_BLOCK_1@@i \le 2\)\(n\)). Each of
the numbers 1, 2, . . . 2\(n\) appears exactly once.
Sum of all \(n\) will be less than or equal to 100 000.

출력 형식

In the \(i-th\) of \(t\) lines print a sequence of zeros and ones representing a possible choice of parentheses. If
parenthesis at index \(a@@RISE_MATH_BLOCK_0@@j\) is chosen, print 1. If there is no valid sequence of parentheses pri\(nt -1\).

서브태스크
서브태스크점수설명

1

10점

\(1 \le n \le 10\)

2

10점

\(z\)[\(a@@RISE_MATH_BLOCK_0@@i\)] for all \(i = 1\), 2, . . . n.

3

20점

\(b@@RISE_MATH_BLOCK_0@@i + 1\) for all \(i = 1\), 2, . . . n.

4

70점

No additional constraints. 1 sekun\(da / 512\) M\(iB / 110\) points

예제 1
입력
1
4
()))((()
1 2
3 5
4 6
7 8
출력
0 1 0 1
예제 2
입력
1
4
)()()()(
1 2
3 4
5 6
7 8
출력
1 1 0 0
예제 3
입력
1
3
(()())
1 6
2 4
3 5
출력
-1
설명

Clarification of the first example:
From the original sequence ()))(((), only the bolded parentheses will remain ()))(((). That is ()(),
which is a valid sequence of parentheses.
Clarification of the second example:
From the original sequence )()()()(, only the bolded parentheses will remain )()()()(. That is (()),
which is a valid sequence of parentheses.

문제 정보

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

출처 COCI 2021/2022 Contest 6

평가 및 의견

Superpozicija

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

Log in to rate problems.

개별 의견

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

풀이 제출

Superpozicija

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