Codeforces Round 1081 (Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2192 Codeforces Round 1081 (Div. 2) FINISHED False 7200 4721123 Feb. 21, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 165 ) F Fish Fight PROGRAMMING dp math probabilities

In a pond, (n) fish are in a line. For each fish (i), its size is (a_i), and any fish that eats it grows by (b_i). Alice picks fish (x), Bob picks fish (y). They alternate turns, starting with Alice's fish. On each player's turn, let their fish have size (p). The fish will eat an adjacent fish with size (q) that satisfies (p \geq q). If more than one such fish exists, it chooses uniformly at random among them. Eating increases its size by the eaten fish's (b_i). If, at the start of its turn, a fish cannot eat any adjacent fish, it is instead eaten by its neighbours (A fish at an endpoint has one neighbour; a fish in the interior has two). If Alice's fish is eaten (either by Bob's fish or by her neighboring fishes), she immediately loses. Similarly, if Bob's fish is eaten (either by Alice's fish or by his neighboring fishes), he immediately loses. Given Alice's and Bob's chosen fishes, compute the probability that Alice wins, modulo (10^9+7). More formally, let (M=10^9+7). The answer can be written as an irreducible fraction (\frac{p}{q}) with (q \not\equiv 0 \pmod M). Output (p \, q^{-1} \bmod M), the unique integer (x) with (0 \le x \lt M) and (x q \equiv p \pmod M). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first line of each testcase contains a single integer (n) ((2 \le n \le 3000)) — the number of fish in pond. The second line contains two integers (x) and (y) ((1 \le x,y \le n); (x \neq y)). The third line contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le 10^9)). The fourth line contains (n) integers (b_1, b_2, \ldots, b_n) ((0 \le b_i \le 10^9)). It is guaranteed that the sum of (n) does not exceed (3000) over all test cases. For each test case output a single integer which is the probab

Tutorials

Codeforces Round 1081 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
363917349 _annhien_ruby22 F Feb. 21, 2026, 6:39 p.m. OK C++17 (GCC 7-32) TESTS 60 156 108748800
363935392 AntiBsayer F Feb. 21, 2026, 10:08 p.m. OK C++17 (GCC 7-32) TESTS 60 171 109056000
363934845 Hasanv F Feb. 21, 2026, 9:57 p.m. OK C++17 (GCC 7-32) TESTS 60 218 140800000
363903382 Raj_Solo F Feb. 21, 2026, 4:33 p.m. OK C++17 (GCC 7-32) TESTS 60 234 477388800
363918849 sumyuckk F Feb. 21, 2026, 6:53 p.m. OK C++17 (GCC 7-32) TESTS 60 343 285184000
363906945 isnim_ylevol F Feb. 21, 2026, 5:20 p.m. OK C++17 (GCC 7-32) TESTS 60 343 289689600
363956347 W_Franklin F Feb. 22, 2026, 5:52 a.m. OK C++17 (GCC 7-32) TESTS 60 843 289689600
363911284 imtweaking F Feb. 21, 2026, 5:51 p.m. OK C++17 (GCC 7-32) TESTS 60 843 361984000
363956617 W_Franklin F Feb. 22, 2026, 5:55 a.m. OK C++17 (GCC 7-32) TESTS 60 906 289689600
363956262 W_Franklin F Feb. 22, 2026, 5:51 a.m. OK C++17 (GCC 7-32) TESTS 60 968 289689600
363899801 PelicanPilot F Feb. 21, 2026, 4:25 p.m. OK C++20 (GCC 13-64) TESTS 60 62 29593600
363902407 LeBronJamesTheGOAT F Feb. 21, 2026, 4:31 p.m. OK C++20 (GCC 13-64) TESTS 60 78 362086400
363927314 ya_ssh F Feb. 21, 2026, 8:15 p.m. OK C++20 (GCC 13-64) TESTS 60 109 153702400
363909954 kosarievGOAT F Feb. 21, 2026, 5:41 p.m. OK C++20 (GCC 13-64) TESTS 60 171 140697600
363901739 aaa_Pigeon2 F Feb. 21, 2026, 4:30 p.m. OK C++20 (GCC 13-64) TESTS 60 171 326963200
363919261 Kude F Feb. 21, 2026, 6:58 p.m. OK C++20 (GCC 13-64) TESTS 60 187 72704000
363900162 aPNJ777 F Feb. 21, 2026, 4:26 p.m. OK C++20 (GCC 13-64) TESTS 60 203 74956800
363942074 ta2ly.id F Feb. 22, 2026, 12:54 a.m. OK C++20 (GCC 13-64) TESTS 60 203 508518400
363901227 kevinyang F Feb. 21, 2026, 4:29 p.m. OK C++20 (GCC 13-64) TESTS 60 218 308736000
363915055 cqrcqr F Feb. 21, 2026, 6:20 p.m. OK C++20 (GCC 13-64) TESTS 60 234 289689600
363909449 lcyxds F Feb. 21, 2026, 5:38 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 93 110489600
363923471 dreamoon_love_AA F Feb. 21, 2026, 7:38 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 93 141107200
363909380 lcyxds F Feb. 21, 2026, 5:38 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 93 220876800
363898866 ttamx F Feb. 21, 2026, 4:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 109 35737600
363953404 thanhnguyxn07 F Feb. 22, 2026, 5:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 60 109 90521600
363946108 _QwQ_TaT_ F Feb. 22, 2026, 2:36 a.m. OK C++23 (GCC 14-64, msys2) TESTS 60 125 217292800
363899479 koukirocks_so_cute F Feb. 21, 2026, 4:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 125 289587200
363927300 dheeraj.dontha F Feb. 21, 2026, 8:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 125 289689600
363911399 1G1U4E5S1T4 F Feb. 21, 2026, 5:52 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 140 108646400
363902516 Dom_inic F Feb. 21, 2026, 4:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 60 140 122368000
363934260 rachit.gupta F Feb. 21, 2026, 9:47 p.m. OK Java 21 TESTS 60 531 213094400
363934210 shubhansh_gupta F Feb. 21, 2026, 9:46 p.m. OK Java 21 TESTS 60 593 212275200
363904120 smilences F Feb. 21, 2026, 4:34 p.m. OK PyPy 3-64 TESTS 60 312 22732800
363908676 Mon_ster F Feb. 21, 2026, 5:32 p.m. OK Rust 2024 TESTS 60 187 122572800

remove filters

Back to search problems