Logo
(追記) (追記ここまで)

25731번 - Making Number 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)73232136.207%

문제

You are given two positive integers $X$ and $Y$ of the same length in base 10. $Z$ is defined as the positive integer in base 10 satisfying the following conditions.

  • The digits of $Z$ should be a rearrangement of the digits of $X$. Leading zeros in $Z$ are not allowed. For example, if $X=1103,ドル $Z$ can be 1103ドル$ or 3101ドル,ドル but $Z$ cannot be 2110ドル,ドル 301ドル,ドル nor 0131ドル$.
  • $Y\leq Z$.
  • $Z$ is the minimum value satisfying the above conditions.

You have to perform $Q$ queries. Each query is one of the followings:

  • Given $i$ and $x,ドル change the $i$-th digit of $Y$ to $x$.
  • Given $i,ドル output the $i$-th digit of $Z$. If there is no such $Z,ドル print $-1$.

The $i$-th digit of a positive integer is defined from the left. For example, The third digit of 1234ドル$ is 3ドル$.

입력

The first line contains two space-separated integers, $X$ and $Y$.

The second line contains a single integer, $Q$.

The following $Q$ lines contain space-separated integers describing the queries. Each line has one of the following forms, where the first integer represents the type of the query:

  • 1 $i$ $x$ : Change the $i$-th digit of $Y$ to $x$.
  • 2 $i$ : Output the $i$-th digit of $Z$. If there is no such $Z,ドル print $-1$.

It is guaranteed that there is at least one query of type 2.

출력

For each query of type 2, output the answer for the query. The answers should be separated by newlines.

제한

Let len$(A)$ be the number of digits in a positive integer $A$.

  • 1ドル\leq X,Y<10^{100,円 000}$
  • 1ドル\leq Q\leq 100,円 000$
  • len$(X) =$len$(Y)$
  • The first digits of $X$ and $Y$ are not 0.
  • For a query of type 1, 1ドル\leq i\leq$len$(Y),ドル 0ドル\leq x\leq 9$. If $i=1,ドル $x\neq 0$.
  • For a query of type 2, 1ドル\leq i\leq$len$(Y)$.

예제 입력 1

3304 1615
6
2 3
2 4
1 1 3
2 2
1 2 4
2 1

예제 출력 1

3
4
0
3

예제 입력 2

838046 780357
10
2 1
2 2
1 2 4
2 3
2 4
1 4 5
2 5
2 6
1 1 9
2 2

예제 출력 2

8
0
3
4
6
8
-1

예제 입력 3

2950 9052
4
2 1
2 2
2 3
2 4

예제 출력 3

9
0
5
2

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2022 KAIST 12th ICPC Mock Competition E번

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 4: KAIST+KOI Contest, Grand Prix of Korea F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /