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'You are given 2n tuples of values (a, b, c) , where a and b are positive integers and c is a bracket '( ' or ') '. Exactly n tuples have c = '( ' and the other n tuples have c = ') '. You are asked to choose two positive values x and y ( x > 0 and y > 0 ; not necessarily integers) and sort the tuples in the increasing value of a cdot x + b cdot y . If several tuples have the same value, you can place them in any order among themselves. Is it possible to choose such x and y that taking brackets c from the tuples in the resulting order produces a regular bracket sequence? A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. The first line contains a single integer t ( 1 <= t <= 1500 ) -- the number of testcases. The first line of each testcase contains a single integer n ( 1 <= n <= 1500 ). The i -th of the next 2n lines contains two integers a_i and b_i ( 1 <= a_i, b_i <= 10^6 ) and a character c_i ( c_i = '( ' or c_i = ') '). Exactly n tuples have c_i = '( ' and the other n tuples have c_i = ') '. The sum of n over all testcases doesn 't exceed 1500 . For each testcase, print "YES" if it 's possible to choose such x and y that taking brackets c from the tuples in the resulting order produces a regular bracket sequence. Otherwise, print "NO". In the first testcase, you can choose x = 10, y = 0.1 . The values for tuples will be 10 cdot 1 + 0.1 cdot 4 = 10.4 and 10 cdot 2 + 0.1 cdot 3 = 20.3 . Thus, the first tuple will go first, then the second one, making the bracket sequence "()", which is regular. In the second testcase, you can 't choose positive x and y such that the openi'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
219393948 |
liuhengxi |
F |
Aug. 18, 2023, 3:39 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
3135 |
426803200 |
|
|
219403011 |
bkifhr10 |
F |
Aug. 18, 2023, 5:41 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
5459 |
303820800 |
|
|
219402976 |
Hell2Evator |
F |
Aug. 18, 2023, 5:40 a.m. |
OK |
GNU C++14 |
TESTS |
69 |
5475 |
303820800 |
|
|
219349228 |
Rahil_Vahora |
F |
Aug. 17, 2023, 4:53 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
982 |
111001600 |
|
|
219349246 |
Morphymorphymorphy |
F |
Aug. 17, 2023, 4:53 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1170 |
86732800 |
|
|
219374609 |
int65536 |
F |
Aug. 17, 2023, 8:50 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1357 |
236032000 |
|
|
219375069 |
int65536 |
F |
Aug. 17, 2023, 8:58 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1403 |
236544000 |
|
|
219375284 |
int65536 |
F |
Aug. 17, 2023, 9:01 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1450 |
192204800 |
|
|
219352312 |
mikky20 |
F |
Aug. 17, 2023, 5:10 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1762 |
504627200 |
|
|
219351068 |
fallleaves07 |
F |
Aug. 17, 2023, 5:02 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1762 |
504627200 |
|
|
219352132 |
fallleaves07 |
F |
Aug. 17, 2023, 5:09 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1824 |
504627200 |
|
|
219374965 |
int65536 |
F |
Aug. 17, 2023, 8:56 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1825 |
236544000 |
|
|
219376679 |
Ant_Man |
F |
Aug. 17, 2023, 9:27 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
1934 |
302796800 |
|
|
219348688 |
kotatsugame |
F |
Aug. 17, 2023, 4:50 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
234 |
76083200 |
|
|
219391431 |
lunchbox |
F |
Aug. 18, 2023, 3:02 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
1621 |
174387200 |
|
|
219359553 |
mo_onrabbit2 |
F |
Aug. 17, 2023, 6:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
1637 |
319488000 |
|
|
219391316 |
lunchbox |
F |
Aug. 18, 2023, 3:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
1699 |
236748800 |
|
|
219391375 |
lunchbox |
F |
Aug. 18, 2023, 3:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
1778 |
236748800 |
|
|
219353456 |
rniya |
F |
Aug. 17, 2023, 5:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
4117 |
242892800 |
|
|
219349019 |
Rubikun |
F |
Aug. 17, 2023, 4:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
4258 |
303923200 |
|
|
219351823 |
rniya |
F |
Aug. 17, 2023, 5:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
5116 |
242892800 |
|
|
219386571 |
phtniit |
F |
Aug. 18, 2023, 1:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
8892 |
512000000 |
|
|
219383842 |
phtniit |
F |
Aug. 18, 2023, 12:45 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
9094 |
512000000 |
|
|
219350402 |
Jackie_Ramziya_Chan |
F |
Aug. 17, 2023, 4:59 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
389 |
202956800 |
|
|
219345811 |
Golovanov399 |
F |
Aug. 17, 2023, 4:38 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
389 |
202956800 |
|
|
219356857 |
Yuu |
F |
Aug. 17, 2023, 5:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
592 |
19558400 |
|
|
219353864 |
Yuu |
F |
Aug. 17, 2023, 5:20 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
608 |
19558400 |
|
|
219390923 |
JoesSR |
F |
Aug. 18, 2023, 2:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
686 |
108339200 |
|
|
219365497 |
SATSKY |
F |
Aug. 17, 2023, 7:06 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
748 |
144384000 |
|
|
219395460 |
vjudge2 |
F |
Aug. 18, 2023, 4:01 a.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
1248 |
509030400 |
|
|
219356224 |
LeoPro |
F |
Aug. 17, 2023, 5:39 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
1528 |
404684800 |
|
|
219378349 |
IgorI |
F |
Aug. 17, 2023, 10:07 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
1543 |
202956800 |
|
|
219345579 |
Gary2005 |
F |
Aug. 17, 2023, 4:37 p.m. |
OK |
GNU C++20 (64) |
TESTS |
69 |
1637 |
304128000 |
|
|
remove filters
Back to search problems