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

Han

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

의견: 0

설명

\(4^{th}\) round, December \(19^{th}\) 2015
Han didn’t want to study solo so he invited his friend Dominik to come over. After an eventful evening
that will be remembered for a record number of solved tasks from the field of electronics, Dominik
went home. To his surprise, the police stopped him thinking he was drunk. It is known that in these
situations sobriety is proven by solving a series of carefully crafted tasks that test a man’s cognitive
abilities. If we can trust Dominik, the conversation went something like this:
Policeman: Something easy to begin with. . . What is the complexity of bubble sort?
Dominik: That is really easy, \(O\)(\(n\)^{2}).
Policeman: Say the English alphabet in reverse.
Dominik: Trivial, zyxwvutsrqponmlkjihgfedcba
Policeman: You learned that by heart. Now imagine that all the letters of the English alphabet from
‘a’ to ‘z’ are respectively written clockwise in a circle. Begin with the letter ‘a’ and say the letters
clockwise. After each spoken letter, I can tell you to continue saying the alphabet in reverse order or
I can ask you how many times so far you’ve said a certain letter. Are you ready? 3, 2, 1, Go!
Dominik: Um... a, b, c...
Write a programme that solves Dominik’s problem.

제약

In test cases worth 40% of total points, it will additionally hold: \(N\) ⩽1000.
In test cases worth 60% of total points, it will additionally hold: \(N\)\(10^{5}\).

입력 형식

The first line of input contains the integer \(Q\) (1 ⩽\(Q\) ⩽100 000), the number of policeman’s orders.
Each of the following \(Q\) lines contains one of the policeman’s order in the form of “SMJER n” (Cro-
atian for direction) or “UPIT n x” (Croatian for query). The order in the form “SMJER n” means
that, after the \(n\)th spoken letter, Dominik must start saying the alphabet in reverse, whereas the order
in the form “UPIT n x” means that Dominik must say how many times so far he’s said the letter \(x\)
in the first \(n\) spoken letters.
The policeman’s order will be given chronologically in the input, or, the numbers \(n\) (1 ⩽\(n\)\(10^{9}\))
from the orders will be strictly ascending. The character \(x\) from the order in the form of “UPIT n x”
is a lowercase letter of the English alphabet.

출력 형식

For each order in the form of “UPIT n x”, output how many times Dominik has said the letter \(x\) in
the first \(n\) spoken letters. The answer to each query needs to be written in a separate line, and the
queries need to be answered in the order given in the input.

예제 1
입력
5
UPIT 1 b
UPIT 3 b
SMJER 4
UPIT 7 a
UPIT 10 z
5
SMJER 1
SMJER 2
SMJER 3
UPIT 5 a
UPIT 7 w
4
UPIT 100 a
UPIT 200 c
UPIT 300 a
UPIT 400 b
출력
output
output
0
1
2
1
2
1
4
8
12
16
설명

Clarification of the first example: Dominik says the following letters: a, b, c, d, c, b, a, z, y, x.
Clarification of the second example: Dominik says the following letters: a, z, a, z, y, x, w.

문제 정보

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

출처 COCI 2015/2016 Contest 4

평가 및 의견

Han

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

Log in to rate problems.

개별 의견

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

풀이 제출

Han

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