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

Ili

설명

Mirko is building a simple logic circuit in his workshop. The circuit consists of \(n\) starting wires denoted
with \(x_{1}\), \(x_{2}\), . . . , \(x_{n}\) and \(m\) logic elements OR denoted with \(c_{1}\), \(c_{2}\), . . . , \(c_{m}\). Each element has exactly two
inputs and one output. Each of the inputs is connected to either a starting wire \(xj\) or to the output of
another element \(cj\). Of course, there are no cycles in a logic circuit and, moreover, it holds that the input
of \(cj\) can be connected to the output of \(ci\) only when it holds \(i < j\).
Each starting wire in the circuit can be set to value 0 or 1, and the value of the output of each element is
the logic OR operation of its inputs — the value is 0 if the values of both inputs are 0, otherwise it is 1.
Mirko does not know the initial values of the starting wires, but with careful measurements, he has
determined the values of the output of some elements. Find the remaining values of the outputs that can
be unambiguously determined based on the measurements.

제약
입력 형식

The first line of input contains the positive integers \(n\) and \(m\) — the number of starting wires and the
number of elements in the circuit. The following line contains a string of exactly \(m\) characters that
describes the measured value of the output of the element \(cj\), or is equal to “?” if Mirko did not perform
this measurement. The \(j^{th}\) of the following \(m\) lines contains labels of two inputs of the circuit \(cj\), each
label being either a label of the starting wire in the form of “xi” where it holds \(1 \le i \le n\), or a label of
the element “ci” where it holds \(1 \le i < j\). The two inputs of the element \(cj\) may be the same. You can
assume that the measured values are mutually consistent.

출력 형식

The first line of output must contain a string of \(m\) characters — the \(j^{th}\) character in the string must
correspond to the value of the output of \(cj\) or be “?” if that value cannot be unambiguously determined.

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

1

7점

\(n \le 15\), \(m \le 20\)

2

42점

\(n \le 500\), \(m \le 500\)

3

51점

\(n \le 10\,000\), \(m \le 10\,000\)

예제 1
입력
4 4
10??
x1 x2
x2 x3
x3 x4
x1 c3
출력
10?1
예제 2
입력
4 5
11???
x1 x2
x3 x4
x1 x3
x2 x4
c3 c4
출력
11??1
문제 정보

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

출처 COI 2017

평가 및 의견

Ili

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

Log in to rate problems.

개별 의견

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

풀이 제출

Ili

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