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 an array a of length n that consists of zeros and ones. You can perform the following operation multiple times. The operation consists of two steps: Determine if it is possible to make all elements of the array equal to zero. If yes, print the operations that lead the the all-zero state. Your solution should not contain more than ( lfloor frac{n}{3} rfloor + 12) operations. Here lfloor q rfloor denotes the number q rounded down. We can show that it is possible to make all elements equal to zero in no more than this number of operations whenever it is possible to do so at all. The first line contains a single integer n ( 3 <= n <= 10^5 ) -- the length of the array. The second line contains n integers a_1, a_2, ldots, a_n ( 0 <= a_i <= 1 ) -- the elements of the array. Print "YES" (without quotes) if the answer exists, otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). If there is an answer, in the second line print an integer m ( 0 <= m <= ( lfloor frac{n}{3} rfloor + 12) ) -- the number of operations in your answer. After that in ( i + 2 )-th line print the i -th operations -- the integers x_i, y_i, z_i . You can print them in arbitrary order. In the first sample the shown output corresponds to the following solution: Other answers are also possible. In this test the number of operations should not exceed lfloor frac{5}{3} rfloor + 12 = 1 + 12 = 13 . In the second sample the only available operation is to flip all the elements. This way it is only possible to obtain the arrays 0 1 0 and 1 0 1, but it is impossible to make all elements equal to zero. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
46240938 |
luogu_bot3 |
E |
Nov. 26, 2018, 7:54 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
46 |
1331200 |
|
2900 |
52147804 |
p0o9i8u |
E |
April 1, 2019, 10:17 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
46 |
1433600 |
|
2900 |
46142601 |
mrsrz |
E |
Nov. 24, 2018, 7:21 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
46 |
2252800 |
|
2900 |
46241454 |
CrazyTeaMajor |
E |
Nov. 26, 2018, 8:18 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
46 |
4812800 |
|
2900 |
57868792 |
lopare |
E |
July 27, 2019, 11:39 p.m. |
OK |
GNU C++11 |
TESTS |
105 |
61 |
1433600 |
|
2900 |
44679343 |
vjudge4 |
E |
Oct. 22, 2018, 5 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
61 |
2048000 |
|
2900 |
45202357 |
ytxytx |
E |
Nov. 2, 2018, 10:49 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
62 |
1843200 |
|
2900 |
45410288 |
Memory_of_winter |
E |
Nov. 7, 2018, 11:46 a.m. |
OK |
GNU C++11 |
TESTS |
105 |
62 |
2252800 |
|
2900 |
44652762 |
GDolphin |
E |
Oct. 21, 2018, 11:58 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
124 |
2355200 |
|
2900 |
44652409 |
CN_zwang2002 |
E |
Oct. 21, 2018, 11:52 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
124 |
2355200 |
|
2900 |
45145949 |
Leafy_ |
E |
Oct. 31, 2018, 4:53 p.m. |
OK |
GNU C++14 |
TESTS |
105 |
46 |
3686400 |
|
2900 |
44680995 |
tmwilliamlin168 |
E |
Oct. 22, 2018, 6:25 a.m. |
OK |
GNU C++14 |
TESTS |
105 |
62 |
2252800 |
|
2900 |
44682964 |
tmwilliamlin168 |
E |
Oct. 22, 2018, 7:42 a.m. |
OK |
GNU C++14 |
TESTS |
105 |
62 |
2355200 |
|
2900 |
44682694 |
tmwilliamlin168 |
E |
Oct. 22, 2018, 7:32 a.m. |
OK |
GNU C++14 |
TESTS |
105 |
62 |
2355200 |
|
2900 |
44681776 |
tmwilliamlin168 |
E |
Oct. 22, 2018, 6:56 a.m. |
OK |
GNU C++14 |
TESTS |
105 |
62 |
2355200 |
|
2900 |
44697725 |
ShadowLight |
E |
Oct. 22, 2018, 1:36 p.m. |
OK |
GNU C++14 |
TESTS |
105 |
62 |
2457600 |
|
2900 |
47505125 |
shadowatyy |
E |
Dec. 25, 2018, 9:49 p.m. |
OK |
GNU C++14 |
TESTS |
105 |
62 |
7270400 |
|
2900 |
44657639 |
zscoder |
E |
Oct. 21, 2018, 1:42 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
78 |
2252800 |
|
2900 |
45239220 |
luogu_bot3 |
E |
Nov. 3, 2018, 10:51 a.m. |
OK |
GNU C++14 |
TESTS |
105 |
109 |
1945600 |
|
2900 |
44894226 |
sdnr1 |
E |
Oct. 26, 2018, 5:43 a.m. |
OK |
GNU C++14 |
TESTS |
105 |
140 |
2048000 |
|
2900 |
44751729 |
ReaLNero1 |
E |
Oct. 23, 2018, 8:19 p.m. |
OK |
GNU C++17 |
TESTS |
105 |
31 |
6451200 |
|
2900 |
44726243 |
redbag |
E |
Oct. 23, 2018, 8:10 a.m. |
OK |
GNU C++17 |
TESTS |
105 |
46 |
1740800 |
|
2900 |
45317607 |
luogu_bot1 |
E |
Nov. 5, 2018, 8:52 a.m. |
OK |
GNU C++17 |
TESTS |
105 |
61 |
1433600 |
|
2900 |
45317471 |
temp6 |
E |
Nov. 5, 2018, 8:49 a.m. |
OK |
GNU C++17 |
TESTS |
105 |
61 |
1433600 |
|
2900 |
44720263 |
TooDumbToWin |
E |
Oct. 23, 2018, 4:30 a.m. |
OK |
GNU C++17 |
TESTS |
105 |
61 |
4915200 |
|
2900 |
45317013 |
temp6 |
E |
Nov. 5, 2018, 8:35 a.m. |
OK |
GNU C++17 |
TESTS |
105 |
62 |
1433600 |
|
2900 |
45248171 |
dimas.kovas |
E |
Nov. 3, 2018, 3:01 p.m. |
OK |
GNU C++17 |
TESTS |
105 |
62 |
1536000 |
|
2900 |
48540219 |
Nakagawa.Kanon |
E |
Jan. 18, 2019, 4:20 p.m. |
OK |
GNU C++17 |
TESTS |
105 |
62 |
2150400 |
|
2900 |
44647270 |
receed |
E |
Oct. 21, 2018, 10:06 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
62 |
2764800 |
|
2900 |
45309329 |
wru |
E |
Nov. 5, 2018, 1:58 a.m. |
OK |
GNU C++17 |
TESTS |
105 |
62 |
2867200 |
|
2900 |
45478180 |
layersOf |
E |
Nov. 9, 2018, 1:27 p.m. |
OK |
Java 8 |
TESTS |
105 |
296 |
3686400 |
|
2900 |
45478678 |
layersOf |
E |
Nov. 9, 2018, 1:39 p.m. |
OK |
Java 8 |
TESTS |
105 |
296 |
5324800 |
|
2900 |
45478447 |
layersOf |
E |
Nov. 9, 2018, 1:32 p.m. |
OK |
Java 8 |
TESTS |
105 |
296 |
5324800 |
|
2900 |
45478224 |
layersOf |
E |
Nov. 9, 2018, 1:28 p.m. |
OK |
Java 8 |
TESTS |
105 |
311 |
3686400 |
|
2900 |
45478150 |
layersOf |
E |
Nov. 9, 2018, 1:26 p.m. |
OK |
Java 8 |
TESTS |
105 |
311 |
3686400 |
|
2900 |
45477652 |
layersOf |
E |
Nov. 9, 2018, 1:13 p.m. |
OK |
Java 8 |
TESTS |
105 |
311 |
3686400 |
|
2900 |
45478242 |
layersOf |
E |
Nov. 9, 2018, 1:29 p.m. |
OK |
Java 8 |
TESTS |
105 |
311 |
3788800 |
|
2900 |
45477736 |
layersOf |
E |
Nov. 9, 2018, 1:16 p.m. |
OK |
Java 8 |
TESTS |
105 |
311 |
3788800 |
|
2900 |
53679863 |
Bruteforceman |
E |
May 2, 2019, 6:25 p.m. |
OK |
Java 8 |
TESTS |
105 |
374 |
0 |
|
2900 |
remove filters
Back to search problems