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

2D Conveyor Belt

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

의견: 0

설명

Farmer John's milk factory can be described by an \(N\) by \(N\)
(\(1 \le N \le 1000\)) grid of cells that contain conveyor belts. Position (\(a,b\))
describes the cell that is in the \(a\)-th row from the top and \(b\)-th column from
the left. There are \(5\) types of cells:

  1. "L" — the cell is a leftward facing conveyor belt which moves all items on it 1 cell left every time unit.
  2. "R" — the cell is a rightward facing conveyor belt which moves all items on it 1 cell right every time unit.
  3. "U" — the cell is an upward facing conveyor belt which moves all items on it 1 cell up every time unit.
  4. "D" — the cell is a downward facing conveyor belt which moves all items on it 1 cell down every time unit.
  5. "?" — Farmer John has not built a conveyor belt at that cell yet.

Note that conveyor belts can also move items outside the grid. A cell \(c\) is
unusable if an item placed at cell \(c\) will never exit the
conveyor belt grid (i.e. it will move around in the grid forever).

Initially, Farmer John has not started building the factory so all cells start
out as "?". For the next \(Q\) (\(1 \le Q \le 2 \cdot 10^5\)) days starting from day
\(1\) and ending at day \(Q\), Farmer John will choose a cell that does not
have a conveyor belt and build a conveyor belt at the cell.

Specifically, during the \(i\)-th day, Farmer John will build a conveyor belt of
type \(t_i\) (\(t_i \in {\text{{L,R,U,D}}}\)) at position (\(r_i,c_i\))
(\(1 \le r_i,c_i \le N\)). It is guaranteed that there is no conveyor belt at
position (\(r_i,c_i\)).

After each day, help Farmer John find the minimum number of unusable cells he
can achieve by optimally building conveyor belts on all remaining
cells without a conveyor belt.

Problem credits: Alex Liang

제약

SCORING

  • Inputs 4-5: \(N \le 10\)
  • Inputs 6-7: \(N \le 40\)
  • Inputs 8-13: No additional constraints

Problem credits: Alex Liang

입력 형식

The first line contains \(N\) and \(Q\).

The \(i\)-th of the next \(Q\) lines contains \(r_i\), \(c_i\), and \(t_i\) in that order.

출력 형식

\(Q\) lines, the \(i\)-th of which describing the minimum number of unusable cells
if Farmer John fills optimally builds conveyor belts on all remaining cells that
do not currently have a conveyor belt.

예제 1
입력
3 5
1 1 R
3 3 L
3 2 D
1 2 L
2 1 U
출력
0
0
0
2
3
설명

The conveyor belt after the fifth day is shown below.

RL?
U??
?DL

One optimal way to build conveyor belts on the remaining cells is as follows.

RLR
URR
LDL

In this configuration, the cells at (\(1, 1\)), (\(1, 2\)), and (\(2, 1\)) are
unusable.

예제 2
입력
3 8
1 1 R
1 2 L
1 3 D
2 3 U
3 3 L
3 2 R
3 1 U
2 1 D
출력
0
2
2
4
4
6
6
9
설명

The conveyor belt after the eighth day is shown below.

RLD
D?U
URL

No matter what conveyor belt Farmer John can build at the center, all cells
will be unusable.

예제 3
입력
4 13
2 2 R
2 3 R
2 4 D
3 4 D
4 4 L
4 3 L
4 2 U
3 1 D
4 1 R
2 1 L
1 1 D
1 4 L
1 3 D
출력
0
0
0
0
0
0
0
0
11
11
11
11
13
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > December > Silver

태그

평가 및 의견

2D Conveyor Belt

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

Log in to rate problems.

개별 의견

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

풀이 제출

2D Conveyor Belt

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