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

Hoof, Paper, Scissors Triples

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

의견: 0

설명

You have probably heard of the game "Rock, Paper, Scissors". The cows like to
play a similar game they call "Hoof, Paper, Scissors".

The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each
other. They both count to three and then each simultaneously makes a gesture
that represents either a hoof, a piece of paper, or a pair of scissors. Hoof
beats scissors (since a hoof can smash a pair of scissors), scissors beats paper
(since scissors can cut paper), and paper beats hoof (since the hoof can get a
papercut). For example, if the first cow makes a "hoof" gesture and the second a
"paper" gesture, then the second cow wins. Of course, it is also possible to
tie, if both cows make the same gesture.

Now there are \(N\) (\(3\le N\le 2\cdot 10^5\)) cows who want to play hoof paper
scissors, and they each independently have a strategy of drawing from some fixed
distribution. In particular, the \(i\)th cow's strategy is to play hoof, paper, or
scissors with probabilities
\(\left(\frac{h_i}{h_i+p_i+s_i}, \frac{p_i}{h_i+p_i+s_i}, \frac{s_i}{h_i+p_i+s_i} \right)\),
respectively.

How many distinct triples of cows (A,B,C) are there such that A beats B on
average, B beats C on average, and C beats A on average? We consider two triples
the same if one equals the other up to a cyclic shift.

Problem credits: Richard Qi

제약

SCORING

  • Inputs 2-3: \(N\le 10\)
  • Inputs 4-9: \(N \le 7500\), the sum of \(N\) over all tests does not exceed \(10^4\)
  • Inputs 10-21: No additional constraints.

Problem credits: Richard Qi

입력 형식

The first line contains \(T\) (\(1\le T\le 5\cdot 10^4\)), the number of independent
tests. Each test is specified in the following format:

The first line contains \(N\).

The next \(N\) lines each contain three non-negative integers \(h_i\), \(p_i\), \(s_i\)
(\(0\le h_i,p_i,s_i\le 10^9, h_i+p_i+s_i>0\)).

It is guaranteed that the sum of \(N\) over all tests does not exceed

출력 형식

Output the number of triples.

Note: The large size of integers involved in this problem may require the use
of 64-bit integer data types (e.g., a "long long" in C/C++).

예제 1
입력
2
4
1 0 0
1 0 0
0 1 0
0 0 1
10
20410069 21445597 257862632
114108992 287498302 113278897
607994331 143503714 631122722
337497016 270153603 320256324
633717786 631078144 493265815
202783212 612643590 560838949
713379081 42803063 58996167
293262767 470686180 220651551
656404313 408797935 345461691
959196297 827681918 591519393
출력
2
32
설명

For the first test, there are two triples: \((1, 3, 4)\) and \((2, 3, 4)\).

문제 정보

riseoj 작성

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

태그

평가 및 의견

Hoof, Paper, Scissors Triples

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

Log in to rate problems.

개별 의견

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

풀이 제출

Hoof, Paper, Scissors Triples

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