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

Lineup Queries

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

의견: 0

설명

There is a line of cows, initially (i.e. at time \(t = 0\)) containing only cow
\(0\) at position \(0\) (here, a cow is at position \(k\) if there are \(k\) cows in
front of it). At time \(t\) for \(t=1,2,3,\dots\), the cow at position 0 moves to
position \(\lfloor t/2\rfloor\), every cow in positions
\(1\dots \lfloor t/2\rfloor\) moves forward one position, and cow \(t\) joins the
line at the end of the line (position \(t\)).

Answer \(Q\) (\(1\le Q\le 10^5\)) independent queries, each of one of the following
types:

  1. At what position is cow \(c\) immediately after time \(t\) (\(0\le c\le t\le 10^{18}\))?
  2. Which cow is at position \(x\) immediately after time \(t\) (\(0\le x\le t\le 10^{18}\))?

Problem credits: Agastya Goel

제약

SCORING

  • Input 3: \(Q\le 1000, t\le 100\)
  • Input 4: \(t\le 5000\)
  • Inputs 5-8: All queries are of type 1.
  • Inputs 9-12: All queries are of type 2.

Problem credits: Agastya Goel

입력 형식

The first line contains \(Q\), the number of queries.

The next \(Q\) lines each contain three integers specifying a query either of the
form "1 c t" or "2 x t."

출력 형식

Output the answer to each query on a separate line.

예제 1
입력
2
1 4 9
2 2 9
출력
2
4
설명

Lineups immediately after various times:

t = 0 | 0
t = 1 | 0 1
t = 2 | 1 0 2
t = 3 | 0 1 2 3
t = 4 | 1 2 0 3 4
t = 5 | 2 0 1 3 4 5
t = 6 | 0 1 3 2 4 5 6
t = 7 | 1 3 2 0 4 5 6 7
t = 8 | 3 2 0 4 1 5 6 7 8
t = 9 | 2 0 4 1 3 5 6 7 8 9

Immediately after \(t=9\), the location of cow \(4\) is \(2\), and the cow located at position \(2\) is
\(4\).

예제 2
입력
22
1 0 9
1 1 9
1 2 9
1 3 9
1 4 9
1 5 9
1 6 9
1 7 9
1 8 9
1 9 9
2 0 9
2 1 9
2 2 9
2 3 9
2 4 9
2 5 9
2 6 9
2 7 9
2 8 9
2 9 9
1 0 1000000000000000000
2 0 1000000000000000000
출력
1
3
0
4
2
5
6
7
8
9
2
0
4
1
3
5
6
7
8
9
483992463350322770
148148148148148148
문제 정보

riseoj 작성

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

태그

평가 및 의견

Lineup Queries

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

Log in to rate problems.

개별 의견

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

풀이 제출

Lineup Queries

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