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

Robot

Gold II 골드 II
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Mirko created a new robot and decided to test it on a giant test track. We can imagine the test track as 2D coordinate system. The robot starts at a point \((0, 0)\) and receives a set of instructions denoted by letters S, J, I, Z, each of them marking a direction in which robot should be moving.

More precisely, if a robot is located in \((x, y)\), S ("north") means it should move to \((x, y+1)\), J ("south") means it should move to \((x, y-1)\), I ("east") means it should move to \((x+1, y)\) and Z ("west") means it should move to \((x-1, y)\).

While robot is receiving instructions and moves through the test track, Mirko is verifying its position in the following manner. Test track contains \(N\) fixed control points. After each instruction is made, each of the control points measures manhattan-distance to the robot. Distances from all control points are then summed and sent to Mirko.

Assuming that robot moves by the instructions without error, calculate the sum of distances to all control points after each instruction.

Remark: manhattan-distance of the points \((x_1, y_1)\) and \((x_2, y_2)\) is equal to \(|x_1 - x_2| + |y_1 - y_2|\).

제약
입력 형식

First line of input contains positive integers \(N\) (number of control points, \(1 \le N \le 100\,000\)) and \(M\) (number of instructions, \(1 \le M \le 300\,000\)), separated by a single space.

Each of the following \(N\) lines contains coordinates of one control point: two space-separated integers \(x, y\), with absolute value less than \(1\,000\,000\) (million). It is possible that two control points have the same coordinates — distance towards each of them is added to the sum.

The following line contains a string of \(M\) characters from the set \(\{S, J, I, Z\}\), the sequence of instructions sent to the robot.

출력 형식

Output \(M\) lines: \(i\)-th line of output should contain the described number after \(i\)-th instruction.

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

Test 1

20점

None

Test 2

20점

None

Test 3

20점

None

Test 4

20점

None

Test 5

20점

None

예제 1
입력
1 3
0 -10
ISI
출력
11
12
13
예제 2
입력
3 5
0 0
1 1
1 -1
SIJJZ
출력
5
4
3
4
5
문제 정보

riseoj 작성

출처 COCI 2011/2012 Contest 3

평가 및 의견

Robot

개요
출제자 난이도 Gold II 골드 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Robot

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