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

Pluses and Minuses

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

의견: 0

설명

Farmer John once painted a rectangular grid on the ground of his pasture. In
each cell, he painted either a \(+\) or a \(−\) (representing \(+1\) and \(−1\),
respectively).

Over time, the paint faded, and Farmer John now remembers the values of only
some cells. However, Farmer John does remember one important fact about the
original painting:

In every row and every column, the sum of the values in any contiguous
subsegment was always between \(−1\) and \(2\) (inclusive).

As an example, consider the row \(\texttt{+ - - +}\). It does not satisfy the
condition, since the subsegment \(\texttt{+ [ - - ] +}\) has sum \(-2\).

However, the row \(\texttt{- + + -}\) does satisfy the condition.

[ - ] + + -    sum = -1
[ - + ] + -    sum = 0
[ - + + ] -    sum = +1
[ - + + - ]    sum = 0
- [ + ] + -    sum = +1
- [ + + ] -    sum = +2
- [ + + - ]    sum = +1
- + [ + ] -    sum = +1
- + [ + - ]    sum = 0
- + + [ - ]    sum = -1

Count the number of different grids consistent with Farmer John's memory.

Problem credits: Alex Chen

제약

SCORING

  • Inputs 3-4: \(\min(R,C)=1\) for all tests
  • Inputs 5-6: \(R,C\le 10\) for all tests
  • Inputs 7-11: \(\sum \max(R,C)^2 \le 10^6\)
  • Inputs 12-14: \(\sum RC \le 10^6\)
  • Inputs 15-22: No additional constraints.

Problem credits: Alex Chen

입력 형식

The first line contains \(T\) (\(1\le T\le 100\)), the number of independent tests.
Each test is specified as follows:

The first line contains \(R\), \(C\), and \(X\) (\(1\le R,C\le 5\cdot 10^5\),
\(0\le X\le \min(10^5,RC)\)), meaning that the grid has dimensions \(R\times C\) and
Farmer John remembers the values of \(X\) different cells in the grid.

Then following \(X\) lines each contain a character \(v\in \{+, -\}\) followed by
two integers \(r\) and \(c\) (\(1\le r\le R, 1\le c\le C\)), meaning that the value at
the \(r\)th row and \(c\)th column of the grid is \(v\). It is guaranteed that no
ordered pair \((r,c)\) appears more than once within a single test.

Additionally, it is guaranteed that neither the sum of \(R\) nor the sum of \(C\)
over all tests exceeds \(10^6\), and that the sum of \(X\) over all tests does not
exceed \(2\cdot 10^5\).

출력 형식

For each test, output the number of grids on a separate line.

예제 1
입력
2
1 3 3
+ 1 3
+ 1 1
- 1 2
1 3 3
+ 1 1
+ 1 3
+ 1 2
출력
1
0
예제 2
입력
1
2 2 0
출력
7
설명

Here are the seven grids:

++
++

++
+-

++
-+

+-
++

+-
-+

-+
++

-+
+-
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > First Contest > Platinum

태그

평가 및 의견

Pluses and Minuses

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

Log in to rate problems.

개별 의견

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

풀이 제출

Pluses and Minuses

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