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 a permutation p consisting of n integers 1, 2, ... , n (a permutation is an array where each element from 1 to n occurs exactly once). Let 's call an array a bipartite if the following undirected graph is bipartite: Your task is to find a bipartite array of integers a of size n , such that a_i = p_i or a_i = -p_i , or report that no such array exists. If there are multiple answers, print any of them. The first line contains a single integer t ( 1 <= t <= 2 cdot 10^5 ) -- the number of test cases. The first line of each test case contains a single integer n ( 1 <= n <= 10^6 ) -- the size of the permutation. The second line contains n integers p_1, p_2, ... , p_n . The sum of n over all test cases doesn 't exceed 10^6 . For each test case, print the answer in the following format. If such an array a does not exist, print "NO" in a single line. Otherwise, print "YES" in the first line and n integers -- array a in the second line. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
139912378 |
Timsei |
F |
Dec. 19, 2021, 4:27 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
405 |
24064000 |
|
|
139890256 |
asrawat2001 |
F |
Dec. 19, 2021, 12:26 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
452 |
20070400 |
|
|
139923158 |
ETK. |
F |
Dec. 19, 2021, 6:58 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
530 |
56115200 |
|
|
139918792 |
fallleaves01 |
F |
Dec. 19, 2021, 5:54 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
296 |
100147200 |
|
|
139873054 |
DerekFeng |
F |
Dec. 19, 2021, 9:07 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
421 |
40038400 |
|
|
139847453 |
NULL0x7f |
F |
Dec. 19, 2021, 1:15 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
436 |
20070400 |
|
|
139864723 |
ModestMouse |
F |
Dec. 19, 2021, 7:21 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
436 |
22425600 |
|
|
139952115 |
_BottomCoder_ |
F |
Dec. 20, 2021, 5:03 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
530 |
52121600 |
|
|
139862337 |
zidder |
F |
Dec. 19, 2021, 6:49 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
608 |
80384000 |
|
|
139835645 |
maximumSHOT |
F |
Dec. 18, 2021, 7:49 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
670 |
76492800 |
|
|
139847848 |
OlavBakken |
F |
Dec. 19, 2021, 1:30 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
701 |
92467200 |
|
|
139950719 |
Zayin |
F |
Dec. 20, 2021, 4:32 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
795 |
100147200 |
|
|
139951086 |
Aging1986 |
F |
Dec. 20, 2021, 4:41 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
966 |
179712000 |
|
|
139871161 |
njwrz |
F |
Dec. 19, 2021, 8:44 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
93 |
87244800 |
|
|
139847917 |
amsraman |
F |
Dec. 19, 2021, 1:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
296 |
16076800 |
|
|
139840507 |
kaiboy |
F |
Dec. 18, 2021, 9:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
296 |
20070400 |
|
|
139829422 |
HEU_Official |
F |
Dec. 18, 2021, 6:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
389 |
56320000 |
|
|
139850319 |
froggyzhang |
F |
Dec. 19, 2021, 2:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
436 |
124108800 |
|
|
139850939 |
fxhd |
F |
Dec. 19, 2021, 3:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
607 |
73216000 |
|
|
139886846 |
blackbird137 |
F |
Dec. 19, 2021, 11:50 a.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
639 |
212172800 |
|
|
139841852 |
HEU_Official |
F |
Dec. 18, 2021, 9:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
1200 |
207769600 |
|
|
139836507 |
arwaeystoamneg |
F |
Dec. 18, 2021, 8:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
1216 |
27443200 |
|
|
139841912 |
HEU_Official |
F |
Dec. 18, 2021, 9:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
1232 |
207769600 |
|
|
139863274 |
Rubikun |
F |
Dec. 19, 2021, 7:02 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
218 |
19456000 |
|
|
139834808 |
Bench0310 |
F |
Dec. 18, 2021, 7:38 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
233 |
24064000 |
|
|
139830354 |
Bench0310 |
F |
Dec. 18, 2021, 6:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
233 |
24064000 |
|
|
139904266 |
chctxdy68 |
F |
Dec. 19, 2021, 2:40 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
312 |
112230400 |
|
|
139829552 |
huangxiaohua |
F |
Dec. 18, 2021, 6:36 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
436 |
56320000 |
|
|
139931116 |
kroyl |
F |
Dec. 19, 2021, 9:46 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
592 |
5017600 |
|
|
139829977 |
huangxiaohua |
F |
Dec. 18, 2021, 6:40 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
716 |
54169600 |
|
|
139902507 |
BlueDiamond |
F |
Dec. 19, 2021, 2:18 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
779 |
256204800 |
|
|
139922287 |
atablash |
F |
Dec. 19, 2021, 6:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
888 |
59596800 |
|
|
139877071 |
Ooops_no |
F |
Dec. 19, 2021, 9:56 a.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
1075 |
246476800 |
|
|
139923457 |
PetrNguyen |
F |
Dec. 19, 2021, 7:02 p.m. |
OK |
Java 11 |
TESTS |
21 |
1403 |
9523200 |
|
|
139923342 |
PetrNguyen |
F |
Dec. 19, 2021, 7:01 p.m. |
OK |
Java 11 |
TESTS |
21 |
1419 |
9523200 |
|
|
139831781 |
Dukkha |
F |
Dec. 18, 2021, 7 p.m. |
OK |
Java 11 |
TESTS |
21 |
1528 |
9523200 |
|
|
139846174 |
conqueror_of_tourist |
F |
Dec. 19, 2021, 12:19 a.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
1575 |
226304000 |
|
|
139846181 |
conqueror_of_tourist |
F |
Dec. 19, 2021, 12:19 a.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
1591 |
226304000 |
|
|
remove filters
Back to search problems