Problem Statement
Note to plugin users: There is an image in this problem statement. Please use the applet to view it.
An insertion into an immutable binary search tree does not alter the existing tree. Rather, it creates a new tree that contains the new value. For example, if a tree contains the values 1, 2, and 3, and you insert the value 4, then the new tree contains the values 1, 2, 3, and 4, but the old tree still exists and still contains only the values 1, 2, and 3. You could next insert, say, 5 into the new tree (obtaining a tree containing 1, 2, 3, 4, and 5) or into the old tree (obtaining a tree containing 1, 2, 3, and 5).
The simplest technique for implementing insertion into an immutable tree is called path-copying, because the entire path from the root to the site of the insertion is copied. Nodes not on this path are shared by the two trees. For example, if we insert 6 into the tree on the left in the picture below, we get the tree on the right.
If we start with an empty tree and perform N insertions, then we end up with a total of N non-empty trees. However, some of those trees may now be garbage, meaning that they are no longer needed and can be deallocated. When we deallocate a tree, we deallocate all of its nodes, except for those nodes that also belong to trees that are not garbage. You must determine how many nodes remain after deallocating all nodes that can be deallocated.
A series of insertions is represented by a
For example, the inputs
values = { 8, 6, 4, 7, 9, 1 } trees = { -1, 0, 1, 0, -1, 2 }correspond to the following series of insertions:
tree0 = insert(8,empty) tree1 = insert(6,tree0) tree2 = insert(4,tree1) tree3 = insert(7,tree0) tree4 = insert(9,empty) tree5 = insert(1,tree2)
The
Definition
- Class:
- ImmutableTrees
- Method:
- numNodes
- Parameters:
- int[], int[], int[]
- Returns:
- int
- Method signature:
- int numNodes(int[] values, int[] trees, int[] garbage)
- (be sure your method is public)
Constraints
- values contains between 1 and 50 elements, inclusive.
- trees contains the same number of elements as values.
- Each element of values is between 1 and 1000, inclusive.
- values contains no duplicate elements.
- Element I of trees is between -1 and I-1, inclusive.
- garbage contains between 0 and N elements, inclusive, where N is the number of elements in values.
- Each element of garbage is between 0 and N-1, inclusive.
- garbage contains no duplicate elements.
Examples
{ 1,2,3,4,5,6,7,8,9 }
{ -1,0,1,2,3,4,5,6,7 }
{}
Returns: 45
{ 3, 2, 5, 4, 1, 6 }
{-1, 0, 1, 2, 3, 4 }
{ 0, 1, 2, 3 }
Returns: 8
The first example above.
{ 8, 6, 4, 7, 9, 1 }
{-1, 0, 1, 0,-1, 2 }
{ 3, 1, 5}
Returns: 5
The second example above.
{ 1, 2, 3, 4 }
{-1, 0, 1, 0 }
{ 0, 1, 2, 3 }
Returns: 0
Everything is garbage.
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50}
{-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48}
{}
Returns: 1275
{6,3,1,4,5}
{-1,0,1,2,2}
{0,1,2}
Returns: 7
{ 206,408,717,861,981,212,374,937,433,707,109,620,167,585,588 }
{ -1,0,1,2,2,-1,-1,5,5,3,2,5,6,-1,10 }
{ 8,1,11,3,13,10,0,14,5,12,9,4 }
Returns: 6
{ 849,991,556,44,382,959,267,671,792,34,708,167,803,971,158,779,275,498,100,824,884,976,455,300,545,719 }
{ -1,-1,1,2,3,0,0,0,4,-1,-1,6,11,12,-1,14,5,0,17,0,17,1,17,20,0,24 }
{ 18,11,19,1,17,12,0,8,25,2,24,10,7,5,20,23,21,6 }
Returns: 22
{ 918,603,7,31,133,717,395,696,817,726,682,250,190,253,205,745,802,136,989,819,835,707,162,367 }
{ -1,-1,-1,0,-1,4,1,0,3,5,-1,2,11,6,9,3,-1,0,12,9,17,19,15,3 }
{ 17 }
Returns: 54
{ 503,419,286,5,888,533,930,151,105,789,472,484,778,902,785,485,412,521,567,643,153,867,755,343,391,963,743,615,995,934,624,442,752,18,363,15,353,951,796 }
{ -1,-1,0,1,0,4,-1,0,4,3,-1,2,0,8,7,4,9,1,3,0,7,12,12,3,9,20,9,24,22,3,28,13,3,18,8,21,14,29,14 }
{ 13,3,22,4,21,0,38 }
Returns: 84
{ 370,108,597,223,473,734,263,554,272,648,480,91,13,665,559,652,266,808,622,958,670,641,869,905,555,807,330,428,677,3,431,667,986,564,154,423,42,515,922,618 }
{ -1,-1,0,1,-1,-1,3,-1,1,1,6,6,0,5,10,1,10,7,17,5,19,3,19,19,18,13,2,4,15,28,22,2,19,32,17,30,3,10,32,37 }
{ 35,29,31,16,27,32,20,0,37,2,38,6,15,3 }
Returns: 70
{ 998,488,303,465,211,600,832,970,544,261,24,218,137,434,224,72,944,359,949,874,163,57,217,517,193,704,215,405,935,609,165,246,603,990,13,533,782,951,620,10,25,396,545,421 }
{ -1,0,0,0,-1,1,1,5,5,6,7,10,9,3,2,10,1,-1,7,12,0,5,1,0,16,6,-1,26,18,22,22,24,30,15,32,7,6,10,22,26,3,18,-1,16 }
{ 19,0,3,24,18,15,5,41,22,4,39,42,31,43,37,20 }
Returns: 95
{ 805,997,960,262,315,11,753,619,799,12,366,176,373,334,744,922,846,852,172,516,855,424,943,41,890,999,128,552,189,502,383,419,677,305,847,857,137,614,393 }
{ -1,-1,0,2,3,1,0,3,4,4,0,10,11,12,3,7,3,7,9,14,11,12,13,20,4,20,11,24,19,23,8,7,12,24,31,0,18,7,14 }
{ 31,26,30,25,1,23,5,29,34,4,16,35,8,12,38,14,21,24,15,37,11,13,18,0,27,20,36,28,7,3,9,22,32,6,2,19,33 }
Returns: 7
{ 858,272,839,65,931,203,35,595,293,95,126,27,148,314,980,335,855,686,921,902,244,230,87,289,951,344,992,349,713,652,423,121,511,913,705,981,747,818,107,614,259 }
{ -1,-1,1,2,3,2,-1,4,1,6,5,4,6,10,3,13,11,10,7,7,17,16,19,20,2,0,24,26,25,3,3,24,24,12,-1,33,35,1,25,38,39 }
{ 13,37,32,35,20,33,26,15,1,27,5 }
Returns: 86
{ 732,889,937,103,177,491,436,583,181,55,362,490,962,127,949,264,206,581,335,592,465,616,284,149,880,731,237 }
{ -1,0,-1,0,0,-1,3,5,4,6,9,6,0,9,0,3,8,1,4,18,14,14,13,18,21,23,20 }
{ 25,13,14,23,22,24,1,8,26,6,10,2,11 }
Returns: 36
{ 288,783,2,53,171,19,275,248,907,389,773,813,415,900,591,700,817,749,119,927,905,375,390,635,793,11,942,866,954,530,758,565,385,326,695,172,474,910,831,857,997,197,724,721,92,674,858,777 }
{ -1,0,0,1,3,3,0,6,0,2,1,-1,3,5,13,2,12,5,5,2,-1,19,20,18,10,9,16,22,4,13,25,22,17,28,13,16,11,19,-1,35,30,32,2,6,19,19,7,39 }
{ 39,16,10,32,40,31,34,44,33,19,1,29,4,36,27,15,8,18,14,28,26,41,9 }
Returns: 70
{ 978,123,687,537,191,481,234,288,79,167,226,622,166,850,445,164,417,439,282,803,696,447,33,21,583,849,614,473,60,794,45,705,463,174,325,883,896,698,914,313,659,457,968,884,868,993 }
{ -1,-1,0,1,-1,-1,0,4,3,5,8,0,0,7,8,13,15,7,2,10,5,10,4,17,5,-1,16,21,5,7,5,2,18,7,26,10,28,11,32,5,37,36,24,29,2,36 }
{ }
Returns: 121
{ 448,728,873,738,391,64,187,843,945,990,852,324,721,569,817,552,985,541,97,330,737,882,547,980,910,346,533,921,243,701,476,538,922,265,807,102,855,645,30,395 }
{ -1,-1,0,0,1,2,3,3,-1,5,5,2,4,4,2,8,0,7,16,15,18,16,21,13,17,1,21,19,-1,15,26,28,9,21,0,29,21,23,10,20 }
{ 5,22,8,10,1,29,34,7,33,32,9,35,2,21,24,26,11,30,31,28,19,4,3,18,16,25,39,37,17,14,13,15,6,23 }
Returns: 21
{ 877,945,67,972,820,670,31,681,263,367,41,914,754,731,910,610,501,661,997,139,322,12,134,926,357,735,808,147,728,187,566,960,347,376,106,247,940,651,315,548,99,72,108,198,181,244,903,404 }
{ -1,0,-1,2,3,-1,5,2,-1,4,9,-1,5,12,12,10,14,13,17,4,5,8,14,0,17,18,-1,7,2,27,8,9,27,19,15,-1,11,20,1,7,35,3,10,15,6,37,15,44 }
{ 3,10,2,13,6,11,4,32,18,27,35,19,37,20 }
Returns: 102
{ 386,981,676,563,949,6,237,546,513,980,132,578,30,446,119,555,645 }
{ -1,0,0,1,2,4,-1,2,1,4,3,7,9,7,13,7,9 }
{ 2,14,3,11,8,6,12,16,0 }
Returns: 26
{ 446,122,232,721,162,314,513,522,41,453,697,432,828,798,758,123,676,575,72,654,250,267,80 }
{ -1,-1,0,0,2,4,1,5,2,7,6,4,-1,0,11,14,4,3,3,18,11,11,6 }
{ 12 }
Returns: 56
{ 16,596,61,81,34,294,634,947,829,453,539,883,776,363,784,553,199,556,769,559,845,802,287,197,364,101,417,915,936,237,155,127,371,562,582,908,779,568,341,445,458,87,751,134 }
{ -1,-1,0,-1,2,4,5,3,2,1,0,7,-1,2,3,10,4,10,14,6,5,11,6,9,22,20,14,18,15,11,1,28,11,13,24,6,24,13,33,12,30,2,40,36 }
{ 32,26,14,40,16,8,6,35,30,33,2,28,12,37,34,10,22,13,1,38,15,36,17 }
Returns: 72
{ 553,632,376,953,516,68,581,294,91,881,121,514,136,691,248,196 }
{ -1,-1,1,1,-1,2,-1,1,0,-1,-1,4,8,1,13,0 }
{ 5,4,10,11,1,15,2,14,3,0,12,6,8,7,9,13 }
Returns: 0
{ 78,17,416,699,993,549,682,996,353,339,109,452,570,523,548,284,599,142,718,385,178,77,351,225,507,129,583,108,984,56,429,665,857,923,754,463,891,818,207,243,208,845,973,634,494,327,75 }
{ -1,0,-1,-1,3,4,4,2,2,3,2,-1,3,3,6,12,4,3,16,8,2,7,14,10,9,20,16,24,7,24,22,6,14,24,32,1,20,29,35,28,39,29,21,3,29,2,17 }
{ 21,8,6,32,17,39,18,4,37,26,27,9,20,5,40,1,22,28,16,44,42,46,25,2,13,12,35,33,3,7,30 }
Returns: 43
{ 406,107,244,641,604,191,178,890,608,624,590,409,596,919,710,335,53,772,740,735,675,131,163,209,931,488,743,186,112,248,413,879,294,876,24,611,493,35,986 }
{ -1,0,-1,-1,-1,0,1,0,2,6,4,8,3,8,10,8,2,8,16,12,17,5,10,18,20,-1,2,2,21,19,13,18,11,5,26,-1,9,14,0 }
{ 7,21,2,18,32,10,19,20,38,23,36,11,35,24,37,1,12,26,16,15,13,17,8,3,25,30,34,4,9,28,0,22,14,6,27,29,31,5 }
Returns: 3
{ 643,391,161,275,751,663,474,165,458,956,960 }
{ -1,0,1,-1,-1,0,3,2,4,7,3 }
{ 10 }
Returns: 20
{ 439,904,454,745,355,66,381,596,307,34 }
{ -1,-1,1,2,1,4,3,2,5,6 }
{ 6,0,2,3,4 }
Returns: 16
{ 953,420,910,823,782,262,803,994,35,284,283,569,40,190,498,265,387,675,930,475,695,662,915,425,202,458,102,29,13,223,763,926,701,659,303,666,874 }
{ -1,0,-1,1,3,2,1,1,3,-1,7,9,11,3,12,7,8,9,16,-1,11,14,12,3,15,11,21,0,26,24,18,2,15,4,4,3,33 }
{ }
Returns: 107
{ 386,115,812,493,543,149,294,990,285,594,520,837,341,973,681,176,27,19,32,21,391,732,534,630,612,314,336,807,201,483,561,921,546,504,828,367,532,519,544,5,261,371 }
{ -1,0,0,-1,2,3,1,4,1,7,2,-1,10,3,5,5,2,8,9,9,10,14,0,12,17,0,25,3,23,4,14,25,2,32,28,27,28,28,24,22,5,31 }
{ 6,4,9,30,23,18,13,0,32,22 }
Returns: 93
{ 75,51,515,992,18,939,904,477,37,170,876 }
{ -1,-1,-1,-1,-1,2,1,3,6,1,3 }
{ 4,9,2,0,5,7 }
Returns: 8
{ 959,158,338,375,114,596,417,43,29,349,692,646,717,985,521,416,532,66,428,956,388,847,282,915,147,745,999,733,77,579,817,983,772,950,350,11,469,343 }
{ -1,-1,0,2,1,3,5,3,7,6,5,3,4,8,5,9,9,5,13,11,18,20,11,20,0,2,1,7,21,20,8,23,11,29,12,9,35,15 }
{ 21,26,14,20,4,10,35,15,12,28,1,22,16,3,5,33,29,18,31,32,11,23,36,6,7,0,2,34,13,37 }
Returns: 35
{ 95,204,696,624,178,730,367,684,944,960,729,971 }
{ -1,0,-1,0,0,3,3,-1,5,2,6,0 }
{ 8,11,9,10 }
Returns: 15
{ 819,865,385,318,912,13,279,29,257,465,935,966,384,441,740,435,588,407,535,701 }
{ -1,0,-1,-1,2,1,4,5,5,4,-1,8,10,9,4,3,14,15,9,16 }
{ 14,8,6,5,17,12,10,19,9,7,0,15,2,1,13,4,3,11,16 }
Returns: 4
{ 778,160,776,506,620,161,418,404,216,275,90,1,782,580,137,645,202,865,43,610,369 }
{ -1,0,1,2,0,4,4,3,6,5,0,2,7,8,4,6,0,16,6,15,15 }
{ 6 }
Returns: 62
{ 312,943,820,211,542,89,376,161,764,648,898,883,727,787,807,603,619,786,574,534,781,106,5,875,543,573,747,449,384,945,279,20,623,679 }
{ -1,-1,1,1,1,0,2,0,7,3,5,4,9,4,1,4,7,12,14,4,12,3,4,2,7,2,10,21,4,9,26,5,24,14 }
{ 29,25,12,6,21,31,24,32,18,7,1,16 }
Returns: 63
{ 985,801,110,371,285,9,456,893,915,971,126,144,7,859,838,983,837,539,730,245,661,433,80,764,67,933,912,904,692,12,674,825,388,929 }
{ -1,0,-1,0,3,0,4,5,6,3,5,10,2,7,9,7,13,7,7,2,5,12,15,21,16,19,13,20,1,12,0,18,29,5 }
{ 3,27,22,18,11,0,10,30,21,29,8,16,1,24,12,14,5,15,28,32 }
Returns: 45
{ 432,602,62,337,284,390,717,515,457,861,290,583,143,242,526,443,367,138,236,637,11,364,842,598,538,103,279,487,490,689,551,8,995,1,970,989,596,751,488,852,795,441,235,695 }
{ -1,-1,-1,0,1,2,1,1,3,6,0,4,1,11,10,3,2,8,7,8,3,19,18,9,5,23,4,12,11,18,16,30,28,1,8,18,26,17,21,26,15,19,18,27 }
{ 17,18,9,40,14,8,33,43,39,13,20,41 }
Returns: 84
{ 715,512,483,961,213,460,145,410,470,191,444,426,376,486,518,927,865,62,59,637,516,962,37,282,107,299,104,44,381,716,587,60,506,730,675,127,100,342,736 }
{ -1,-1,1,1,0,2,0,-1,3,5,4,4,3,9,12,13,14,0,3,2,10,2,14,21,-1,6,12,9,24,10,19,27,22,23,1,27,6,30,31 }
{ 13,26,33,17,24,1,3,38,7,9,27,37,25,21,30,18,11,16,23,29,19,34,8,6,36,31,5,0,28,22,12,4,2,14,32,15 }
Returns: 13
{ 21,438,541,553,202,231,790,764,761,505,642,912,631,7,519,175,40,443,332,247,53,349,355,322,58,577,550,526,199,882,245,871,843,940,217,407,957,899,588 }
{ -1,0,0,0,0,2,-1,0,6,0,-1,6,-1,0,1,13,3,5,10,0,13,15,11,17,0,3,18,15,-1,14,12,29,20,9,32,21,17,7,18 }
{ 32,18,2,24,35,7 }
Returns: 84
{ 931,516,426,40,667,963,404,471,940,921,71,138,965 }
{ -1,0,-1,0,0,3,1,2,7,7,7,9,9 }
{ 8,1,5,11 }
Returns: 20
{ 885,929,154,202,380,880,4,352,758,874,639,947,986,674,633,622,703,76,671,26 }
{ -1,0,-1,1,3,1,3,5,3,-1,5,0,10,6,4,5,1,14,6,8 }
{ 8,13,11,19,4,14,1,6,2,18,10,5,3,16,12,17,15 }
Returns: 6
{ 104,403,766,72,851,668,816,378,865,482,794,646,242,718,303,382,214,924,179,916,188,400 }
{ -1,-1,0,2,0,2,5,6,5,7,5,7,7,10,6,0,10,8,9,10,14,9 }
{ 11,3,20,7,10,13,15,4,5,9,0,19,1,8,18,14,16 }
Returns: 21
{ 971,360,15,615,680,913,277,757,463,751,401,631,193,687,886,941,868,211,619,511,20,444,528,909,935,82,265,14,460,923,394,46,777,51,749,509,683,922,336,289,621,77,113 }
{ -1,0,1,0,3,0,-1,0,4,0,0,2,-1,0,4,4,9,2,9,14,13,5,4,14,3,2,16,10,17,4,9,26,6,9,18,15,10,3,33,34,11,38,13 }
{ 17,3,8,35,11,24,9,31,27,22,23,34,21,26,25,32,29,28,30,18,4,15,14,41,5,10 }
Returns: 48
{ 675,14,300,586,532,249,118,60,336,858,533,400,947,602,198,804,785,372,276,776,352,108,110,51,244,564,56,518,572,434,410,550,160,711,979,740,755,65 }
{ -1,0,0,0,0,1,-1,4,-1,1,3,10,9,12,9,10,-1,1,13,17,2,10,4,0,6,11,24,11,24,20,16,27,18,28,26,20,19,36 }
{ 22,29,4,33,35,19,21,9,2,6,37,15,31,13,11,25,23,3,26,27,7,36,34,12,32 }
Returns: 34
{ 51,917,991,815,59,646,625,223,191,171,968,575,961,851,357,808,861,716,47,967,723,887,429,993,532 }
{ -1,0,-1,1,-1,1,3,5,3,8,-1,2,8,4,4,3,8,3,10,6,10,1,15,12,5 }
{ 0,7,9,15,21,14,24,1,23,2,4,19,20,5,3,12,6 }
Returns: 24
{ 664,765,471,167,479,449,402,282,333,563,111,774,730,445,721,415,931,158,641,902,615,171,892,372,943,9,128,469,140,576,940,496,74,184,729,748,191,836,375,674,105,808,645 }
{ -1,-1,-1,0,3,2,5,6,4,1,7,10,3,11,11,4,13,6,4,0,3,6,18,18,6,2,11,20,0,4,14,5,11,27,24,30,31,18,21,-1,25,31,4 }
{ 24,41,25,16,37,36,11,10,35,22,20,2,31,1,19,38,34,9,17,33,15,39,3,0,12,32,18,7,29,27,13,14,5,30,42,6,40,26,4 }
Returns: 15
{ 397,660,786,449,187,441,421,712,713,366,778,23,874,57,691,255,822,918,513,297,484,812,706 }
{ -1,0,-1,0,2,-1,2,0,4,-1,6,9,10,1,5,6,5,10,14,5,3,17,17 }
{ 22,12,7,0,14,21,6,13,2,9,5,16,18,3,4,19,20,15,1 }
Returns: 10
{ 829,413,338,912,102,628,970,466,1,444,436,293,814,34 }
{ -1,-1,0,2,-1,2,4,1,1,1,7,8,2,10 }
{ }
Returns: 29
{ 799,743,727,417,566,319,985,60,897,380,59,430,538,309,69,990,580,636,989,567,26,24,568,855,161,98,153,541,473,767,449,362,648,272,993,96,45,185,472,50,176,979,42,52,921,574,510 }
{ -1,0,0,1,0,2,5,0,1,5,9,0,1,10,0,13,13,2,2,8,3,12,8,14,21,24,2,3,16,28,29,30,20,28,8,3,4,30,25,32,11,24,0,30,23,16,1 }
{ 36,7,46,37,6,0,14,28,29,8,22,24,27,41,42,13,20,43,39,34 }
Returns: 110
{ 338,438,320,756,385,945,894,292,538,592,342,133,790,111,13,805,766,900,344,717,506,589,306,252,249,980,197,929,654,977,622,624,834,544 }
{ -1,-1,0,0,1,0,4,2,3,3,6,6,5,12,13,1,7,0,17,10,4,14,8,10,13,15,-1,23,9,23,10,13,15,29 }
{ 24,16,2,20,17,3,25,12,22,33,18,11 }
Returns: 61
{ 258,507,917,902,558,481,530,224,700,83,534,93,568,771,823 }
{ -1,-1,1,-1,0,1,-1,5,0,8,9,0,5,11,7 }
{ 11,1,8,0 }
Returns: 24
{ 184,426,97,385,83,305,710,591,992,663,28,790,415,258,897,477,481,860,153,260,382,731,369,706,285,571,124,853 }
{ -1,0,1,-1,3,3,2,6,5,2,3,-1,1,9,8,12,15,6,15,18,1,18,11,2,7,16,13,15 }
{ 17,4,18 }
Returns: 71
{ 805,759,622,733,829,393,112,218,537,20,436,113,217,707,576,863,720,640,722,268,756,65,239,124,571,378,125,972,59 }
{ -1,0,1,-1,0,-1,1,0,6,5,6,2,3,2,1,8,13,15,13,6,16,20,7,13,19,15,22,18,26 }
{ 22,12,18,15,27,1,26,20,7,11,2,28,8,9,23,19,21,4,16,5,24,3 }
Returns: 26
{ 50,866,357,385,356,525,451,349,128,418,161,935,740,120,885,96 }
{ -1,-1,-1,-1,1,-1,-1,6,3,7,8,6,5,1,12,0 }
{ 12,9,2,6,0,3,13,7,11,4,15,1,10,5,8 }
Returns: 3
{ 943,726,220,224,44,171,605,547,581,708,384,512,665,618,623,885,573,991,566,479,712,146,239,279,663,54,661,811,248,31,353 }
{ -1,-1,1,1,0,4,3,-1,1,6,9,2,9,7,10,6,-1,11,14,15,10,2,20,16,3,20,2,5,8,28,3 }
{ 2,23,28 }
Returns: 85
{ 99,864,524,749,340,495,305,678,734,657,907,900,604,252,508,886,956,962,363,195,341,638,526,401,914,230,144,936,635,707,865,724,622,791,872,606,554,162,393,432,523,679,431 }
{ -1,-1,1,1,-1,0,4,4,3,1,3,2,-1,10,0,7,7,16,12,17,15,9,11,14,4,20,10,12,23,10,18,16,31,9,28,16,11,11,1,2,2,19,9 }
{ 15,38,42 }
Returns: 102
{ 935,777,438,242,768,867,983,277,282,531,825,643,473,90,435,326,699,551,301,878,583,392,595,970,650,706,683,50,848,521,485,28,89,125,772,215,279,42,382,181,101,661,231,817 }
{ -1,0,1,1,0,2,4,1,3,-1,4,4,4,9,5,9,-1,10,10,5,18,11,17,1,1,8,16,-1,-1,18,18,20,4,11,3,31,2,2,3,19,15,15,1,30 }
{ 13,37,19,26,9,23,34,22,11,43,25,41,24,29,42,6 }
Returns: 87
{ 149,886,132,967,578,40,746,304,205,592,87,63,312,904,316,259,469,737,755,483,244 }
{ -1,0,1,1,2,1,1,0,0,4,5,9,6,2,12,2,-1,10,5,2,9 }
{ 13,12,7,0,19,6,18,15,10,14,1,4,5,20,17,8,2,3,9 }
Returns: 7
{ 334,964,184,106,128,731,644,239,375,804,830,845,915,68,48,346,66,710,997,861,223,872,373,995,55,327,856,554,2,340,145,331,400,172,633,649,619,134,827,271,548,77,984,568,676,20,662,890,700 }
{ -1,0,-1,0,-1,0,1,0,7,2,4,-1,9,10,6,8,13,12,7,7,8,2,6,3,21,8,11,26,26,2,13,5,19,21,3,15,16,36,8,15,6,24,19,16,22,18,7,31,26 }
{ 36,5,38,15,24,30,20,4,34,1,27,13,23,44,46,48,2,35,8,14,28,26,9,0,6,45,21,33,31,40,29,42,16,47,37,12,22,39,10,17,3,32,7,18,19,41,11 }
Returns: 9
{ 582,860,289,946,498,291,960,500,87,492,834,943,240,352,404,600,754,913,745,873,829,338,269,414,227 }
{ -1,-1,-1,-1,2,-1,0,0,4,0,2,8,-1,5,13,1,1,12,11,9,3,11,2,17,12 }
{ 7,14,12,5,13,15,10,3,1,4,8,17,20,9,16,6,18,19,22,23,0,2,21,11 }
Returns: 2
{ 971,941,824,999,401,788,768,913,252,548,655,177,136,506,843,868,365 }
{ -1,-1,1,-1,2,2,2,-1,-1,-1,5,0,8,7,13,10,2 }
{ 15,13,7,8,2,1,4,16,14,11 }
Returns: 15
{4,2,6,1,3,5,7}
{-1,0,1,2,3,4,5 }
{}
Returns: 17
{ 599,939,333,338,46,956,15,441,748,342,290,824,225,566,409,298,913,808,118,147,864,927,628,107,573,779,138,29,611,756,532,70,27,787,610,135,950,794,625,203,414,798,955,873,206,424,456,177,440,570 }
{ -1,-1,0,0,3,3,1,3,7,8,7,9,2,6,-1,1,4,11,5,2,5,20,18,11,12,8,10,26,3,4,5,18,10,28,32,27,26,30,22,10,39,26,9,38,43,12,18,29,23,5 }
{ 22,20,4,38,14,2,29,36,12,32,10,13,21,3,39,18,41,43,33,7 }
Returns: 110
{ 406,26,379,18,742,133,254,675,864,842,561,627,511,721,332,73,607,577,526,84,25,130,466,228,778,877,82,157,940,587,10,67,730,1,590,85,223,633,136,323,116,988,659,801,792,132,366,454,709,857 }
{ -1,0,-1,2,0,-1,5,1,4,1,3,5,3,3,0,9,1,14,7,1,10,20,7,-1,1,-1,22,6,5,2,7,22,7,-1,0,14,21,26,23,0,9,26,22,1,23,34,34,43,13,30 }
{ 3,42,44,22,35,43,24,38,13,26,32,39,8,2,48,45,20,25,40,36 }
Returns: 74
{ 760,990,545,912,615,784,503,313,256,476,900,771,684,9,373,242,524,230,616,635,671,206,868,594,785,380,814,757,759,304,262,177,74,954,108,358,420,5,363,612,977,750,775,252,151,231,75,566,142,178 }
{ -1,-1,0,-1,1,0,-1,5,-1,6,9,7,0,4,6,1,10,6,13,2,2,14,-1,6,20,17,8,14,16,12,25,21,19,20,8,-1,10,32,34,18,27,18,12,21,4,17,40,18,20,9 }
{ 39,27,32,34,42,1,6,14,15,46,11,29,13,18,3,24,7,37,23,40 }
Returns: 81
{ 598,93,594,345,86,751,517,406,143,271,620,302,171,937,78,133,611,18,317,132,965,88,29,280,464,328,140,254,842,522,278,113,485,549,45,324,223,777,889,150,681,85,343,183,391,389,359,473,651,719 }
{ -1,-1,1,1,2,4,0,5,2,-1,8,6,4,8,5,4,-1,3,15,6,8,5,18,21,19,5,1,10,15,23,27,20,6,31,19,23,5,22,5,20,16,4,13,26,4,13,5,39,45,5 }
{ 8,6,2,21,15,23,5,3,32,36,33,42,19,20,34,44,10,41,13,27 }
Returns: 102
{ 998,429,310,969,714,963,101,386,627,149,606,835,146,784,205,232,30,541,508,696,238,571,172,369,213,212,339,712,170,726,57,940,128,810,399,981,920,895,994,255,277,71,822,35,587,2,752,19,928,486 }
{ -1,-1,0,1,0,4,0,4,4,8,9,-1,9,11,13,4,15,14,8,6,16,0,2,5,10,15,10,23,19,20,21,23,4,9,33,11,2,16,-1,10,2,12,29,10,39,33,3,29,47,7 }
{ }
Returns: 175
{ 61,67,46,42,38,11,88,33,9,20,31,68,48,17,74,91,15,62,21,73 }
{ -1,0,0,2,3,3,-1,6,5,4,2,0,10,0,0,8,3,10,6,12 }
{ 17,11,18,1,10,12,2,6,0,4 }
Returns: 34
{ 98,63,31,62,83,72,45,44,90,80,48,11,42,70,19,20,82,8,92,58,25,5,67,2,21,12,56,49,13,37,60,41,53,18,35,66,33,15,51,77 }
{ -1,-1,0,1,3,-1,5,-1,6,8,7,1,9,6,12,5,3,14,11,10,10,19,-1,12,16,15,9,22,-1,-1,16,22,8,24,-1,6,8,4,21,13 }
{ 32,5,29,18,0,37,38,30,39,9,7,17,25,8,12,11,28,21,22,1 }
Returns: 54
{ 37,12,11,7,10,36,17,19,18,23,8,31,32,15,21,4,25,33,29,22,5,3,34,20,13,30,1,35,2,9,14,27,28,16,24 }
{ -1,0,1,2,3,3,3,2,-1,1,0,5,11,1,4,12,3,15,6,12,4,13,19,1,0,14,7,12,18,12,3,26,21,29,24 }
{ 13,14,6,31,9,30,15,5,24,3,27,8,34,16,20 }
Returns: 85