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

Plaće

Platinum III 플래티넘 III
난이도
1.500s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Mirko loves cars and he finally managed to start his own car factory! Factory has \(N\) employees, each of them has exactly one superior (except Mirko — he is by default everybody's superior). Mirko is denoted by number \(1\), and the rest of the employees with numbers \(2\) to \(N\).

Every employee can raise or lower the wages of all of his subordinates (both direct subordinates and those lower in the hierarchy tree). Mirko's role is to prevent abuse of such power, so from time to time he wants to know wage of a particular employee.

He is asking you to write a program which will help him monitor wage changes, given a sequence of commands described in the input section.

Remark: at any time, all of the wages will be positive integers and will fit in standard 32-bit integer type (int in C/C++, longint in Pascal).

제약
입력 형식

First line of input contains two space-separated positive integers \(N\) (\(1 \le N \le 500\,000\)), number of employees, and \(M\) (\(1 \le M \le 500\,000\)), number of wage changes and wage queries.

Next \(N\) lines contain the information about employees \(1, 2, \dots, N\) (respectively): starting wage and the identifier of his direct supervisor. Remark: Mirko has no supervisor, so his line will contain only his starting wage.

Next \(M\) lines contain one of the following:

  1. p A X — employee \(A\) increases (or decreases in case of a negative \(X\)) wage of all his subordinates by the amount \(X\) (\(-10\,000 \le X \le 10\,000\));
  2. u A — Mirko wants to know the wage of employee \(A\).
출력 형식

Output should contain one line for each ‘2’ query in the inp\(ut - th\)e current wage of the given employee.

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

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
2 3
5
3 1
p 1 5
u 2
u 1
출력
8
5
예제 2
입력
5 5
4
2 1
6 1
7 1
3 4
u 3
p 1 -1
u 3
p 4 5
u 5
출력
6
5
7
예제 3
입력
6 7
5
4 1
3 2
7 3
2 3
3 5
p 3 2
p 2 4
u 3
u 6
p 5 -2
u 6
u 1
출력
7
9
7
5
문제 정보

riseoj 작성

출처 COCI 2011/2012 Contest 3

평가 및 의견

Plaće

개요
출제자 난이도 Platinum III 플래티넘 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Plaće

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