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

35018번 - Asynchronous Processor 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB1255100.000%

문제

You are given a program consisting of $n$ instructions executed by a processor with a single integer register $A,ドル initially equal to 0ドル$. Each instruction is one of two types:

  • "+ v" --- performs $A := A + v$;
  • "= v" --- performs $A := v$.

The instructions in the program are numbered from 1ドル$ to $n$. Each instruction $i$ initially has timestamp $i$.

Some instructions are marked as asynchronous. If instruction $i$ is asynchronous, its timestamp can be changed to any real number greater than $i$.

After all timestamp adjustments, all timestamps must be distinct. The processor then executes the instructions in order of increasing timestamp.

Determine the number of distinct final values of $A$ that can be obtained after all instructions have been executed, considering all possible choices of asynchronous instruction timestamps.

입력

The first line contains an integer $n,ドル denoting the number of instructions in the program (1ドル \le n \le 2000$).

The $i$-th of the following $n$ lines describes instruction $i$ and contains three tokens. The first token is either '+' or '=', denoting the type of the instruction. The second token is an integer $v,ドル denoting the argument of the instruction (1ドル \le v \le 500$). Finally, the third token is either "async" if the instruction is marked as asynchronous, or "sync" otherwise.

출력

Print the number of distinct final values $A$ can take after executing the program.

제한

예제 입력 1

3
+ 1 sync
= 2 async
+ 3 async

예제 출력 1

2

예제 입력 2

10
= 7 async
+ 3 async
+ 5 sync
+ 3 async
= 1 sync
+ 9 async
+ 10 async
+ 1 sync
+ 3 async
+ 4 sync

예제 출력 2

30

노트

In the first test, the program execution starts with instruction 1ドル$ setting $A$ to 1ドル$. Then, instructions 2ドル$ and 3ドル$ are executed in one of the two orders:

  • if "= 2" is executed before "+ 3", $A$ will be equal to 5ドル$;
  • if "+ 3" is executed before "= 2", $A$ will be equal to 2ドル$.

Thus, there are two possible values of $A$ at the end: 5ドル$ and 2ドル$.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2025-2026 Northwestern Russia Regional Contest A번

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

출처

대학교 대회

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

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