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.
Problems
B"Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries. Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the army should consist of some subset of them. The i -th mercenary can be chosen if the resulting number of chosen mercenaries is not less than l_i (otherwise he deems the quest to be doomed) and not greater than r_i (he doesn't want to share the trophies with too many other mercenaries). Furthermore, m pairs of mercenaries hate each other and cannot be chosen for the same quest. How many non-empty subsets does Polycarp need to consider? In other words, calculate the number of non-empty subsets of mercenaries such that the size of this subset belongs to [l_i, r_i] for each chosen mercenary, and there are no two mercenaries in the subset that hate each other. The answer may be large, so calculate it modulo 998244353 . The first line contains two integers n and m ( 1 <= n <= 3 cdot 10^5 , 0 <= m <= min(20, dfrac{n(n-1)}{2}) ) -- the number of mercenaries and the number of pairs of mercenaries that hate each other. Then n lines follow, the i -th of them contains two integers l_i and r_i ( 1 <= l_i <= r_i <= n ). Then m lines follow, the i -th of them contains two integers a_i and b_i ( 1 <= a_i < b_i <= n ) denoting that the mercenaries a_i and b_i hate each other. There are no two equal pairs in this list. Print one integer -- the number of non-empty subsets meeting the constraints, taken modulo 998244353 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
91640721 |
luogu_bot5 |
G |
Sept. 2, 2020, 12:36 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
249 |
57753600 |
|
|
91640688 |
Juanzhang |
G |
Sept. 2, 2020, 12:36 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
265 |
57753600 |
|
|
91565665 |
AutumnKite |
G |
Sept. 1, 2020, 12:43 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
326 |
77209600 |
|
|
91562828 |
AutumnKite |
G |
Sept. 1, 2020, 12:02 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
326 |
77209600 |
|
|
91177314 |
charlieyan |
G |
Aug. 28, 2020, 3:50 a.m. |
OK |
GNU C++11 |
TESTS |
96 |
327 |
105062400 |
|
|
91132178 |
yasugongshang |
G |
Aug. 27, 2020, 12:23 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
327 |
110592000 |
|
|
91564821 |
hzk_cpp |
G |
Sept. 1, 2020, 12:30 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
342 |
71577600 |
|
|
91564639 |
hzk_cpp |
G |
Sept. 1, 2020, 12:27 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
342 |
71577600 |
|
|
91140924 |
mwlc |
G |
Aug. 27, 2020, 2:25 p.m. |
OK |
GNU C++11 |
TESTS |
96 |
373 |
85299200 |
|
|
91605423 |
priority |
G |
Sept. 2, 2020, 1:45 a.m. |
OK |
GNU C++11 |
TESTS |
96 |
436 |
63692800 |
|
|
91221427 |
K0u1e |
G |
Aug. 28, 2020, 3:17 p.m. |
OK |
GNU C++14 |
TESTS |
96 |
451 |
57753600 |
|
|
91222947 |
K0u1e |
G |
Aug. 28, 2020, 3:32 p.m. |
OK |
GNU C++14 |
TESTS |
96 |
452 |
57753600 |
|
|
91210773 |
George1123 |
G |
Aug. 28, 2020, 1:17 p.m. |
OK |
GNU C++14 |
TESTS |
96 |
483 |
59494400 |
|
|
91182193 |
_no0B |
G |
Aug. 28, 2020, 5:47 a.m. |
OK |
GNU C++14 |
TESTS |
96 |
514 |
295424000 |
|
|
91179615 |
achibulup |
G |
Aug. 28, 2020, 4:53 a.m. |
OK |
GNU C++14 |
TESTS |
96 |
608 |
111820800 |
|
|
91657251 |
Hexan |
G |
Sept. 2, 2020, 4:03 p.m. |
OK |
GNU C++14 |
TESTS |
96 |
701 |
113049600 |
|
|
91219651 |
selia |
G |
Aug. 28, 2020, 2:59 p.m. |
OK |
GNU C++14 |
TESTS |
96 |
717 |
113049600 |
|
|
91125407 |
tzxydby |
G |
Aug. 27, 2020, 10:47 a.m. |
OK |
GNU C++14 |
TESTS |
96 |
779 |
146739200 |
|
|
91125596 |
vjudge1 |
G |
Aug. 27, 2020, 10:50 a.m. |
OK |
GNU C++14 |
TESTS |
96 |
811 |
146739200 |
|
|
91182161 |
_no0B |
G |
Aug. 28, 2020, 5:46 a.m. |
OK |
GNU C++14 |
TESTS |
96 |
1075 |
295424000 |
|
|
91297216 |
Noureldin |
G |
Aug. 29, 2020, 3:54 p.m. |
OK |
GNU C++17 |
TESTS |
96 |
483 |
132915200 |
|
|
91211860 |
vjudge3 |
G |
Aug. 28, 2020, 1:30 p.m. |
OK |
GNU C++17 |
TESTS |
96 |
530 |
108236800 |
|
|
91467211 |
swust5120177231 |
G |
Aug. 31, 2020, 7:14 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
561 |
214425600 |
|
|
91191398 |
wangziji |
G |
Aug. 28, 2020, 8:23 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
654 |
137113600 |
|
|
91318699 |
xiejun |
G |
Aug. 30, 2020, 2:18 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
701 |
63795200 |
|
|
91107696 |
YZHOvO |
G |
Aug. 27, 2020, 6:18 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
717 |
284364800 |
|
|
91177411 |
Chanyuh |
G |
Aug. 28, 2020, 3:54 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
763 |
121856000 |
|
|
91554502 |
Mr.Robot_28 |
G |
Sept. 1, 2020, 9:58 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
795 |
119193600 |
|
|
91121451 |
MrGary |
G |
Aug. 27, 2020, 9:47 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
826 |
107520000 |
|
|
91176422 |
limabeans |
G |
Aug. 28, 2020, 3:22 a.m. |
OK |
GNU C++17 |
TESTS |
96 |
826 |
111820800 |
|
|
91315550 |
ecnerwala |
G |
Aug. 29, 2020, 11:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
171 |
11468800 |
|
|
91173103 |
wwdd |
G |
Aug. 28, 2020, 1:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
343 |
28364800 |
|
|
91132641 |
daifucong |
G |
Aug. 27, 2020, 12:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
530 |
56627200 |
|
|
91620835 |
handlecurrentinuse |
G |
Sept. 2, 2020, 7:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
561 |
62566400 |
|
|
91478100 |
JJLeo |
G |
Aug. 31, 2020, 9:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
561 |
64819200 |
|
|
91132325 |
I_am_the_winner_ |
G |
Aug. 27, 2020, 12:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
701 |
31641600 |
|
|
91117836 |
ivan100sic |
G |
Aug. 27, 2020, 8:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
701 |
94310400 |
|
|
91195948 |
Koo_ |
G |
Aug. 28, 2020, 9:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
717 |
222412800 |
|
|
91145652 |
nishank.suresh |
G |
Aug. 27, 2020, 3:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
858 |
56524800 |
|
|
91145869 |
nishank.suresh |
G |
Aug. 27, 2020, 3:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
96 |
873 |
56524800 |
|
|
91315417 |
mphillotry |
G |
Aug. 29, 2020, 11:05 p.m. |
OK |
Java 11 |
TESTS |
96 |
2183 |
70860800 |
|
|
91095362 |
LeoRiether |
G |
Aug. 27, 2020, 12:14 a.m. |
OK |
Rust |
TESTS |
96 |
1653 |
95232000 |
|
|
91104515 |
sansen |
G |
Aug. 27, 2020, 5:20 a.m. |
OK |
Rust |
TESTS |
96 |
2168 |
199475200 |
|
|
91095347 |
LeoRiether |
G |
Aug. 27, 2020, 12:14 a.m. |
OK |
Rust |
TESTS |
96 |
2433 |
95948800 |
|
|
remove filters
Back to search problems