Statistics

Problem Statement for "FoxAirline"

Problem Statement

Fox Ciel has an airline company: Fox Airline. The company currently offers several one-directional flights.

There are n airports in the region serviced by Fox Airline. The airports are numbered 0 through n-1. You are given the int n. You are also given three int[]s: a, b, and c. These contain information about the flights offered by Fox Airline: For each valid i there is a flight from the airport a[i] to the airport b[i]. The cost of operating this flight is c[i] dollars per year.

Fox Ciel would now like to cut some costs while making sure she allows her customers to travel everywhere. More precisely, Ciel is going to choose some of the flights she currently operates, and cancel all others. She has two goals:
  • For any two airports x and y there must be a way to travel from x to y by only using chosen flights.
  • Given the above rule, the total cost of chosen flights (in dollars per year) must be as small as possible.
If Ciel can achieve her goal, return the smallest possible total cost of the chosen flights. If there is no valid way to choose the flights, return -1.

Definition

Class:
FoxAirline
Method:
minimalCost
Parameters:
int, int[], int[], int[]
Returns:
int
Method signature:
int minimalCost(int n, int[] a, int[] b, int[] c)
(be sure your method is public)

Constraints

  • n will be between 1 and 12, inclusive.
  • a will contain between 0 and n*(n-1) elements, inclusive.
  • a, b and c will contain same number of elements.
  • Each element in a will be between 0 and n-1, inclusive.
  • Each element in b will be between 0 and n-1, inclusive.
  • Each element in c will be between 1 and 100,000, inclusive.
  • For each valid i, a[i] will be different from b[i].
  • For each valid and different i and j, the ordered pair (a[i], b[i]) will be different from (a[j], b[j]).

Examples

  1. 3

    {0,0,1,2,1,2}

    {1,2,0,0,2,1}

    {1,1,1,1,10,10}

    Returns: 4

    It is possible to only keep three flights, but that is not the cheapest solution. Instead, we should choose the first four flights. The total cost is only 1+1+1+1 = 4, and it is still possible to travel from any airport to any other airport.

  2. 3

    {0,1,0,1}

    {1,0,2,2}

    {1,2,3,4}

    Returns: -1

    There is no valid solution, even if we choose all flights, we can't get from city 2 to city 0.

  3. 4

    {0,1,2,3}

    {1,2,3,0}

    {10,20,30,40}

    Returns: 100

    We need to choose all flights.

  4. 5

    {0,1,2,3}

    {1,2,3,0}

    {10,20,30,40}

    Returns: -1

  5. 12

    {5,7,1,9,5,7,3,1,11,8,1,10,2,7,8,7,2,11,6,4,6,9,4,4,3,7,1,0,4, 10,0,6,6,8,9,0,6,6,11,10,5,5,9,0,11,3,5,0,9,7,7,5,11,8,1,8,3, 4,7,4,3,8,3,4,3,8,10,0,11,11,0,6,4,0,1,6,0,3,0,9,11,2,1,3,8,1, 2,4,11,1,7,5,5,9,9,7,5,2,4,8,2,10,3,9,5,0,11,3,2,6,6,1,6,4,2, 9,10,11,10,2,7,8,8,2,10,2,10,9,1,5,10,10}

    {0,3,2,3,3,11,0,4,1,0,9,3,1,8,5,9,5,2,11,1,1,2,7,9,4,2,0,10,0, 0,7,2,9,4,4,9,7,8,8,8,9,2,11,11,10,10,4,6,5,10,6,10,0,2,3,10, 1,3,0,2,2,6,5,11,6,3,5,8,6,3,2,4,10,5,5,5,4,9,3,8,7,4,7,11,7, 10,11,8,4,8,4,11,8,7,10,5,6,7,5,1,9,2,8,0,1,1,5,7,0,3,0,11,10, 6,8,6,1,9,9,6,1,9,11,3,6,10,7,1,6,7,11,4}

    {25984,89713,21689,14734,59359,53691,32670,17291,10665,7734, 78780,41871,51780,29833,83512,65961,1102,19919,82940,78302, 33977,93139,34297,40731,43477,27993,57723,12152,3980,70786, 35521,70833,64827,59029,43895,90715,48944,83551,24446,16475, 87602,93225,97981,94059,22358,99691,62932,90503,97309,87273, 52990,70178,95405,60529,54542,18236,3626,390,7246,93273,91896, 95133,94136,17526,40131,66971,3155,80877,27302,35933,20726, 36474,60672,64932,97730,17345,80773,3805,33962,10994,41796, 94727,81676,52518,36032,67199,99638,79108,39564,48423,20062, 43372,78076,70519,6529,80526,64653,68090,49366,82926,96800, 46972,3187,21071,40295,59157,98610,21594,64406,26409,54502, 32364,42991,32988,31586,90087,48361,86876,32023,64035,36642, 25221,35100,6541,61459,22219,93856,34767,87048,90635,29986, 21603}

    Returns: 189591

  6. 1

    {}

    {}

    {}

    Returns: 0

  7. 12

    {5,9,10,10,6,8,10,9,5,10,8,1,10,3,11,3,7,11,6,9,2,7,5,6,7,1,11,6,7,2, 11,4,3,3,8,7,4,0,1,8,11,10,6,9,10,4,2,11,5,5,6,2,6,2,1,4,4}

    {9,1,4,11,4,1,0,2,3,1,3,0,7,6,2,11,2,7,11,6,5,9,10,0,6,8,6,1,1,1,0,5, 5,10,7,11,8,1,4,0,10,2,2,11,8,6,4,8,11,7,9,0,3,6,5,9,7}

    {79862,9,74319,12776,32621,80260,79081,6,6,10,37161,23193,10,4,50002, 90283,12508,1834,8,3445,5698,10,4391,6,24057,1,13679,36429,72785,5, 54330,40592,9,5,5,38969,8,1658,5,6,2,3,36180,4,99092,85511,33081,224, 41612,86028,84781,23905,94493,7,41185,4,7}

    Returns: 7406

  8. 12

    {3,6,9,4,5,6,9,2,4,10,10,2,1,5,0,6,9,1,5,8,6,0,10,5,9,11,6,6,2,5,9,3,11,4,3,6,0,10,11,10,8,5,7,2,10,10,3,7,1,11,1,2,8,9,5,2,1,2,7,0,3,0,1,4,11,8,2,1,8,3,9,1,5,0,10,3,1,6,9,2,9,7,0,2,7,1,5,8,3,4,5,10,5,7,10,8,3,4,11,7,6,4,10,11,11,0,8,3,0,9,7,0,6,11,4,8,6,4,11,2,7,1,3,7,4,11,7,0,9,4,8,8}

    {0,7,5,1,10,10,3,3,10,9,6,5,6,6,11,2,6,7,0,2,1,4,8,8,4,4,4,0,11,11,0,4,2,11,1,9,2,3,1,2,11,4,2,7,4,0,5,6,0,5,4,1,10,11,7,9,10,10,1,8,8,10,8,3,0,6,8,3,1,9,8,11,9,6,7,11,2,5,1,4,10,4,3,0,10,9,2,4,10,6,1,11,3,11,5,0,7,7,9,9,3,5,1,10,7,9,7,2,7,7,8,5,11,6,8,5,8,0,8,6,5,5,6,0,2,3,3,1,2,9,9,3}

    {35434,70099,47177,72686,34748,49405,87310,44571,67950,20306,81578,62110,25367,42615,32172,1319,69448,523,14949,19311,74953,11440,3554,4903,42921,60131,75411,40070,61561,75607,62758,58886,80823,69238,60899,94981,85653,90756,3308,67143,96687,16550,90403,6184,46715,81413,86446,34468,93368,56560,62007,91299,48161,53849,63466,52756,93267,12821,24869,7744,99037,69801,73124,36774,79504,71765,35243,5429,8973,83362,9741,37681,14297,28417,89402,56241,5207,96812,99270,7319,4453,59820,25081,88600,45584,51887,89502,75266,51468,30589,47159,52265,90750,13878,53369,67860,41718,93190,81077,5352,70616,30526,56612,49763,28012,96418,58235,35086,97554,18668,36960,97921,58761,52214,14473,46531,88205,54992,18364,36448,3104,31571,4885,6196,47924,59702,35204,72358,78503,96201,75170,31132}

    Returns: 95413

  9. 12

    {4,0,1,5,9,8,3,11,2,1,8,3,10,11,1,9,9,6,0,9,8,4,5,2,1,2,8,9,4,3,5,0,6,8,10,10,2,1,9,10,6,10,0,8,1,5,11,8,0,4,9,1,5,5,11,3,9,2,2,1,7,0,5,3,7,0,4,10,7,0,3,2,8,7,11,3,7,10,7,6,3,2,3,0,6,5,10,8,8,4,1,8,4,4,9,2,6,5,5,11,6,9,0,11,4,0,6,2,7,11,10,6,1,7,10,11,11,11,1,3,2,9,6,4,5,7,10,7,3,7,6,4}

    {5,10,7,11,6,4,8,2,11,10,6,4,4,1,2,7,5,1,8,10,0,3,7,7,0,9,9,1,0,2,10,9,9,7,0,11,1,11,8,2,3,3,3,3,9,8,8,11,5,8,0,8,1,4,4,7,11,4,5,3,6,2,2,0,3,4,7,6,2,11,5,10,2,10,10,9,4,7,9,11,10,8,6,7,4,6,8,1,10,2,5,5,10,11,4,6,5,0,3,6,2,2,6,5,1,1,8,0,1,3,5,10,6,0,1,0,7,9,4,1,3,3,0,6,9,8,9,11,11,5,7,9}

    {36351,77192,86653,43399,15656,34927,68124,48270,19448,50840,89777,3358,27226,84812,99689,45522,99499,65878,67216,21313,50497,62411,65797,59602,4410,93008,17629,66263,87591,42505,7445,8992,50528,59040,95643,92495,13044,35271,61345,98294,58837,47676,64832,52973,13027,18428,96370,27874,92435,67063,68732,35637,517,50114,97691,78045,84519,26202,17784,6307,19943,13198,26217,87580,19690,19679,41709,24615,67684,11894,84776,43695,73870,46001,62101,63275,93734,13939,88618,78109,50533,36811,89964,74469,35127,93417,79767,15961,79181,13606,16230,4531,70786,83927,90518,16587,30877,93111,78625,69426,88239,73582,95507,73710,77546,64424,5391,61896,2200,83066,97890,34877,85593,14884,87054,77025,57419,54733,21759,77039,755,26270,30659,68565,62190,80547,10548,22278,16172,79522,41877,64046}

    Returns: 153491

  10. 12

    {5,7,1,2,4,2,5,4,8,8,2,2,2,3,5,0,4,9,1,10,0,5,1,9,11,6,11,8,5,6,2,9,4,7,7,6,9,10,9,2,11,3,0,0,9,10,4,10,7,5,6,1,5,10,3,0,10,11,9,6,3,3,1,1,10,6,11,4,0,2,8,2,11,11,10,4,6,3,10,2,6,11,8,2,0,7,3,7,8,9,1,7,8,4,5,8,5,7,7,1,0,8,11,6,5,5,4,3,6,3,1,7,8,4,9,0,6,1,11,3,10,0,10,1,9,7,9,8,11,3,0,4}

    {6,10,11,8,6,1,11,2,11,0,7,6,0,11,9,11,0,6,6,9,10,1,5,1,4,1,8,1,10,9,5,5,7,8,1,3,0,2,10,4,0,2,8,1,7,5,11,11,11,8,7,0,2,7,1,3,6,10,4,10,4,9,2,7,8,11,1,10,2,9,4,10,3,5,1,8,4,0,0,3,5,9,10,11,6,3,7,2,5,11,8,0,3,1,0,6,3,9,5,3,7,7,2,8,4,7,9,6,2,10,4,4,2,5,8,5,0,9,7,5,3,9,4,10,2,6,3,9,6,8,4,3}

    {7339,72450,63369,69822,36818,3969,40276,40746,83638,59378,76698,95986,65041,99196,16537,56151,55487,74379,59448,40452,25666,18338,41673,77599,76964,55629,36250,88,52793,17599,28831,67903,9298,18728,9661,88445,89315,60472,28111,49075,84186,43272,93121,68720,37740,69078,81614,47088,41919,51986,51955,55286,19583,17536,54502,20914,32210,66462,42509,92444,33129,91073,67021,19214,86114,18205,97815,74977,52948,85200,22119,92340,7276,57345,45734,28039,74152,62328,77040,97878,81736,48143,38357,63796,42278,31139,14654,64623,13253,71092,16190,95267,73406,47653,79925,4127,24385,79497,90515,77823,61913,22964,47398,89578,99443,72510,80127,29838,56346,76743,31332,64847,16834,73023,64510,4574,69566,71001,81080,87939,13256,98103,89236,45336,30494,15976,88897,60363,6564,4350,91442,95150}

    Returns: 213603

  11. 12

    {11,10,3,2,9,0,4,4,5,7,1,9,1,11,9,6,2,11,11,3,3,7,0,8,8,0,0,5,6,8,0,4,7,7,4,4,11,6,0,11,3,1,5,6,5,6,0,1,11,11,8,3,9,10,7,9,5,11,10,7,3,2,3,4,11,7,11,10,10,0,3,0,10,7,2,8,4,4,9,7,10,8,4,3,0,9,5,6,1,6,2,5,1,2,8,9,4,5,10,8,5,3,5,10,2,8,1,6,3,2,10,2,0,4,9,2,5,1,6,6,2,1,9,8,7,1,8,9,1,6,10,7}

    {6,11,7,10,6,11,2,7,1,6,8,8,11,5,5,0,6,3,9,0,9,11,5,1,2,4,3,6,4,5,9,3,4,5,6,11,7,2,2,4,1,5,9,9,2,7,1,2,1,2,10,5,0,0,10,7,7,0,9,0,10,3,2,0,10,3,8,3,8,6,6,10,7,2,5,7,9,8,10,9,5,6,10,8,8,2,0,10,0,5,9,11,3,1,4,4,1,4,1,11,10,4,8,4,11,9,10,8,11,0,2,8,7,5,11,4,3,7,1,11,7,4,1,3,1,6,0,3,9,3,6,8}

    {96503,34590,70565,63163,21646,66072,701,31351,3902,17065,36490,9321,1677,8411,41676,63552,91877,196,32266,80101,88607,91478,537,84796,11279,90259,85888,42330,53471,94750,78549,85260,6598,7481,83228,18528,29074,49741,30410,87168,88917,92907,47077,11197,43544,11320,53636,41477,82730,89522,63331,58588,13385,59899,2731,75323,81869,59896,53395,49654,32906,13011,8199,4230,27242,12660,28384,50999,50001,40543,7887,32044,47417,25915,53934,92163,82903,22466,98378,88831,40076,19830,26244,23407,81226,73574,43652,90689,75565,83865,2867,97917,19554,12113,4605,68770,62252,5018,95449,50425,63551,64274,2908,70806,55379,75933,41583,31052,60476,68833,78118,36898,13857,88494,9000,94636,84547,82118,78004,40486,90160,15037,78661,33144,43954,91891,41266,94854,58689,71171,96689,79439}

    Returns: 91162

  12. 12

    {4,0,6,4,10,5,2,11,0,3,5,8,4,7,7,7,4,4,3,6,4,2,2,8,8,7,9,9,7,8,9,9,0,6,8,8,10,0,10,2,6,6,11,2,5,2,4,7,9,2,9,7,3,11,11,3,3,1,10,1}

    {3,7,2,2,0,10,4,6,8,11,0,4,5,6,5,10,0,6,6,1,10,9,8,1,7,0,7,6,11,9,5,11,11,11,0,5,1,4,8,3,0,8,3,7,8,1,9,1,3,10,2,4,1,10,5,7,4,3,3,11}

    {8,8,3,69200,86845,78041,5,62971,6,92768,45760,7228,7,27886,28209,45751,2,7,27688,31911,10,68137,14886,5,3,3,3,75507,34502,99073,6,3,83815,45383,58021,4,67101,64439,90246,7,8,68483,6,78870,2,25244,96091,10,27279,5,9,85911,6,19458,3310,13805,6,3,6,8}

    Returns: 68199

  13. 12

    {1,7,9,1,8,9,7,4,11,5,9,1,0,5,7,1,2,3,9,0,6,1,2,11,9,3,2,6,8,3,1,11,11,10,4,7,4,2,6,5,5,6,0,1,0,3,8,1,4,5,3,2,4,7,10,3,10,0,7,4,1,7,11,3,10,5,6,11,0,6,7,4,10,7}

    {2,10,1,7,4,7,9,2,0,10,8,4,2,8,4,3,5,8,3,3,1,6,10,10,2,6,0,4,5,5,11,9,8,11,11,0,0,7,7,6,2,5,7,0,8,11,0,5,7,4,2,4,10,5,3,7,2,9,11,9,10,8,7,1,6,1,2,2,10,0,2,6,5,1}

    {73721,2,4,10,9,56552,2,3,65427,4,1,49594,378,3,6,12628,20248,70377,7,9,54283,27617,46471,7594,3,50626,72493,76977,5,66749,75951,49840,53305,2,39594,21795,61864,4,89938,9130,4174,50905,15438,80021,4977,99683,86824,53116,87265,97479,45759,27778,68678,76405,35864,57759,98105,62513,26994,34094,24152,69681,4,93079,23461,24320,63758,6,67490,9,8,2,32041,18172}

    Returns: 45821

  14. 12

    {6,11,11,8,6,7,7,8,9,0,0,5,4,6,7,2,6,11,1,9,6,9,1,0,10,1,0,8,8,3,8,10,11,1,3,4,6,0,2,0,1,7,11,9,8,1,3,8,1,10,5,4,2,5,10,4,5,2,6,4,8,9,10,0,2,7,0,11,6,5,8,9,10,4,6}

    {7,3,2,11,9,1,11,0,8,4,5,7,2,0,8,8,11,1,0,11,2,6,8,10,8,10,9,2,3,4,9,5,9,6,9,6,5,3,9,8,11,10,10,0,4,5,6,6,7,3,0,1,6,3,1,10,8,11,10,9,5,7,0,2,5,6,6,0,8,4,1,4,2,8,3}

    {5,79180,34640,4,22416,5202,37396,9,41794,58676,17643,2,32659,67034,25931,15867,7882,91150,2,6,1,18705,4931,1,94700,52196,45561,27691,7,97952,8,76220,4,54528,14141,46704,3,2,1,79607,81455,34864,9233,39626,1,10,7,2,68533,12590,63684,48629,36418,22734,60876,16817,6,91307,35296,98165,1,14509,3,10,54046,2,4,74366,8,9,20830,65630,19036,4,66731}

    Returns: 14473

  15. 12

    {0,9,11,8,0,8,3,6,11,10,3,2,9,4,11,1,7,11,4,9,10,7,10,10,7,9,10,3,8,7,0,7,1,4,2,4,8,1,4,5,8,5,10,9,3,3,4,5,0,11,6,1,6,3,2,10,2,2,7,1,11,1,6}

    {4,3,8,7,6,11,0,7,6,1,8,0,6,1,0,10,3,2,11,10,7,10,9,3,8,4,6,1,3,1,5,2,8,10,11,3,5,4,7,6,0,11,8,1,10,6,6,3,7,10,8,3,5,7,6,11,5,3,5,11,9,2,1}

    {32402,23789,8487,90613,1,29106,11497,7,89651,93518,24269,10568,20597,91428,79448,9,7,8,45142,59751,35197,7,81453,74659,2,72967,12208,72842,23009,7,7,99982,10,4,2,36884,2,56150,9,92336,99612,81654,6216,6,1,3,6356,6,8,3,1,17015,9,4,59482,36312,79172,3,6,14760,44910,93344,88304}

    Returns: 108895

  16. 12

    {4,4,5,0,0,1,10,3,2,5,6,7,6,5,10,0,11,7,1,10,9,7,2,8,10,10,6,11,5,6,10,11,0,9,2,11,1,11,7,1,6,10,6,4,10,9,2,8,2,6,5,3,3,1,9,5,4,9,9,9,10,4,0,4,8,5,4,2}

    {0,9,10,10,1,8,4,5,6,6,11,10,5,2,3,7,4,6,2,11,10,0,1,1,1,5,3,6,7,7,2,5,4,5,11,9,6,7,2,9,4,7,8,8,8,4,7,11,3,0,3,6,4,11,8,4,6,6,0,11,9,11,5,5,10,0,2,10}

    {22493,90771,7,99337,36417,16796,9,8,13821,4,2,74913,5,1224,4,55691,9,8,3,65959,70634,9,19759,9744,51962,68812,2,46067,4,89652,11102,8,57999,9,45944,70860,2,1,26305,81972,70337,9,9,59385,1,9,48751,6896,79731,70930,8,7,23951,92777,99084,4,3,4,7,5,3,7,80230,9,2,15223,75182,80564}

    Returns: 50286

  17. 12

    {10,11,4,0,5,0,4,9,10,7,8,6,3,11,11,8,5,0,1,5,11,1,11,3,10,4,9,11,10,7,10,8,6,6,6,7,1,9,5,6,9,1,3,0,2,2,2,1,4,8,2}

    {5,1,8,9,9,3,0,2,4,5,7,0,10,0,9,3,10,1,2,8,4,7,3,11,9,1,3,10,1,1,11,5,3,7,4,3,3,7,6,10,10,5,6,11,5,10,3,4,3,4,0}

    {62018,69029,60741,3,1,708,56680,35235,27872,71136,6,55454,55,7,2386,4,6195,9060,11980,9,26383,30085,91902,82771,33912,71531,3,2,16416,92315,92679,95399,65745,85880,30219,596,39304,4,10,77481,7560,5,42510,2175,22618,6880,14112,65754,39382,14488,17879}

    Returns: 118737

  18. 12

    {1,8,0,10,7,6,3,9,3,4,11,6,6,0,6,1,7,5,11,11,6,10,9,3,8,7,5,8,11,1,6,5,8,2,8,11,3,8,9,11,11,1,0,2,3,9,4,7,9,1,10,9,3,2,11,4,0,4,0,6,8,8,5,0,6,11,10,9,3,5,1,1,5,10,6,1,2,7,2,7,10,3,9,11,4}

    {3,11,4,9,8,0,10,6,1,6,0,7,4,11,10,0,4,1,5,7,5,3,5,6,4,1,9,5,8,9,1,10,0,10,7,1,7,9,11,4,2,7,8,11,5,0,8,3,7,2,7,2,0,5,6,5,9,0,2,3,6,3,6,6,8,10,6,1,9,7,8,10,3,1,11,6,0,2,3,5,5,8,3,3,1}

    {64504,41745,79464,19149,89717,3913,7099,88133,17215,78746,73680,80489,68301,50232,6119,37931,99032,71095,53523,98630,90120,55197,37977,71808,54555,46625,31828,90571,52390,82887,41113,29215,80386,18175,91745,15351,66774,95128,79133,84014,91132,13020,13021,19587,94971,41697,83790,74946,5927,54692,24622,77995,42519,29278,83362,63234,73236,27932,76684,45595,19984,19742,19979,67398,83160,43656,10723,52624,1326,10219,2282,14458,32649,40045,73023,86825,63918,21657,83515,13001,83638,98290,73286,92892,10574}

    Returns: 208977

  19. 12

    {1,2,11,1,1,3}

    {8,9,9,3,4,10}

    {94683,18443,54664,5864,82846,30221}

    Returns: -1

  20. 12

    {11,5,0,5,0,6,9,6,3,9,11,10,11,11,7,1,10,5,6,2,8,6,9,0,4,2,10,11,2,8,9,0,1,2,3,0,0,6,9,11,1,2,8,4,4,9,7,1,0,3,1,11,6,8,2,4,2,11,5,2,9,1,10,9,5,6,10,7,10,7,7,8,3,10,8,5,5,7,1,9,7,6,3,5,6,11,2,0,4,6,5,3,0,8,2,1,11,4,7,6,7,8,7,3,8,2,3,11,9,10}

    {7,11,6,7,7,7,6,2,6,2,1,9,6,5,4,9,3,4,4,3,10,1,1,2,3,4,5,2,1,5,3,3,2,9,0,8,1,10,5,4,8,0,0,0,10,10,0,6,9,10,11,10,8,9,7,9,6,0,3,8,7,7,6,8,1,9,11,8,2,10,9,3,7,7,6,10,2,1,4,11,6,3,11,9,0,9,5,4,1,11,0,4,10,7,11,5,3,8,5,5,3,1,11,9,2,10,2,8,4,4}

    {2,42016,4,9,7,9,94359,6,50912,51511,6,9589,2,35475,84515,27032,9,59240,7533,69821,10,7,2,58851,60992,1,22052,95782,40877,3,63515,31209,18559,9,16661,5,98550,1,4,7,81428,4,44601,7,21571,8,60512,51648,93869,4986,31174,9,3,44501,75711,8,8351,4221,61957,69265,48581,3,8,7,1,6,10,95906,5388,86868,72002,44872,1,13834,1287,6,72203,86462,70061,9,7,8502,5769,9,4,41477,4,24133,5,7,38498,5,7,1,1,34272,9,91828,59951,92601,9,8,1,9,3327,73658,8,15000,48055,7}

    Returns: 47

  21. 12

    {5,3,2,6,5,4,10,3,4,0,8,6,8,7,4,9,6,5,9,6,2,3,6,11,9}

    {11,4,9,3,8,6,0,9,7,4,6,10,5,2,11,0,8,1,10,1,0,2,4,3,11}

    {41897,75281,81799,56276,39643,9,66043,4,9361,35212,1826,10,73980,70350,56433,73252,18421,55246,65832,41275,28587,51877,76659,22689,76494}

    Returns: -1

  22. 12

    {0,7,2,6,5,4,8,9,11,6,4,2,5,7,6,5,2,11,1,7,1,6,4,5,7,8,8,11,8,10,0,2,6,4,4,4,1,2,11,10,1,6,1,10,1,3,7,0,3,9,10,8,6,3,9,11,5,3,2,8,10,7,5,2,5,7,9,9,2,9,11,11,5,9,11,11,10,0,5,3,9,0,7,10,4,1,0,6,10,0,8,9,10,1,11,3,2,3,1,9,6,2,8,5,1,5,0,8,4,6,7,3,4,0,4,3,9,3,8,7}

    {7,0,6,0,2,11,5,2,10,5,7,3,9,3,11,8,4,7,2,10,9,2,9,11,1,1,3,6,6,11,10,5,7,5,0,10,6,0,5,6,3,10,0,8,8,6,2,3,5,1,1,10,9,7,7,2,7,11,11,2,3,6,4,8,3,9,3,8,7,0,4,0,0,6,3,8,7,8,6,10,10,6,4,2,3,5,5,3,4,2,9,5,0,11,9,9,10,8,4,4,8,9,0,1,10,10,1,4,2,1,11,4,1,11,8,0,11,2,7,8}

    {699,84344,9987,9130,96645,85348,50195,36338,18321,2,88415,73643,20222,18295,71007,92968,72851,1,77829,83850,76123,87674,27852,25987,48900,2,9,1,16641,55889,86384,4,10,99214,43015,9,71629,6,67373,5444,5,22715,40047,32575,39219,62422,38936,71922,6,99780,69953,90644,96688,7322,68847,93911,14569,26499,77463,26049,4411,67783,92359,9,975,45117,10,21231,83135,47487,45036,45366,9,89997,75800,2,61983,65744,17987,15677,80927,10,9,6079,13113,8,93713,98476,6,10941,71432,23873,95187,3,51528,48023,5660,93417,43539,83459,83000,74456,21135,96980,76768,79675,11699,95941,9952,8468,1682,71629,49269,42101,5,77780,82799,72020,2,30260}

    Returns: 26379

  23. 12

    {8,7,9,1,8,9,11,3,9,9,1,11,7,6,5,5,7,8,2,4,9,0,10,1,6,5,0,0,3,3,11,10,10,4,6,7,3,5,2,9,11,4,10,0,6,8,5,8,4,3,11,4,9,0,5,4,10,10,5,2,4,10,7,7,11,8,11,9,1,3,5,11,6,8,3,1,1,2,3,7,8,5,3,0,8,4,1,7,10,2,2,5,6,7,6,6,11,6,2,10,2,0,9,6,0,7,10,3,6,11,9,11,8,9,3,0,5,2,8,4,10,0,1,0,2,2}

    {7,1,8,9,10,6,8,7,3,11,2,9,5,11,4,1,11,5,10,2,1,6,3,10,5,2,11,7,1,11,2,6,9,8,7,4,5,9,5,10,0,0,2,3,9,1,11,6,9,10,4,3,7,5,0,7,1,0,6,1,5,5,0,3,1,9,7,4,4,8,3,10,10,0,6,6,3,4,2,9,2,10,9,1,11,11,8,2,8,6,0,8,1,8,0,4,3,8,11,4,9,10,2,2,8,6,7,4,3,6,0,5,3,5,0,9,7,3,4,6,11,4,0,2,8,7}

    {3,3,8,10,2,4,4,36865,7,2,1,2,34340,2052,99042,5,3,7,3,9,5,1,6,6,7,4,5,7,76914,6,4,6,7,6,6,2,3,31354,3,35701,5,10,1,24866,3,5,27217,3,6,10,74893,5,10,1,28235,2,4,5,7,10,5,9,2,25790,7,7,74434,4,6,9,6,57185,9,78293,9,7,9,2,8,24416,1,2,3,6,10,9,5,82971,3,6,14975,18943,10,69051,5,9,9,9,3,7,8,97072,2,95547,1,2,8,86940,10,4,9,2,5,1,1,9,8,35183,1,10,3,7,8,10,44566,80235}

    Returns: 27

  24. 12

    {7,3,9,6,1,11,5,3,7,4,11,11,4,6,11,2,8,0,3,3,1,3,7,7,3,5,4,5,0,4,4,6,10,7,11,6,10,0,5,10,10,2,9,7,4,1,7,10,2,8,10,3,8,11,8,6,2,1,8,9,10,9,3,4,6,5,8}

    {3,10,1,10,7,6,11,4,1,3,1,9,5,4,10,11,2,1,7,8,6,1,4,0,9,2,9,1,7,11,10,2,9,2,0,0,2,3,3,3,7,0,7,9,0,9,5,0,5,0,6,5,3,7,11,3,1,2,5,0,8,2,2,1,9,10,10}

    {72878,7986,4,7,4,8,6,3,7,3,3,2,8,9,5,7,7,10,3,85905,7,2,8,2,6,5,8,4,10,5,1,23637,2,10,61666,27964,8,9,4,10,1,29593,1,1,10,34057,5,2,5,9,6,4,10,9,3,4,7,8,2,76465,7,3,1,9,9,2,9}

    Returns: 48

  25. 12

    {5,6,4,5,9,3,0,3,7,2,11,0,4,11,1,2,1,3,5,4,0,10,4,7,3,10,4,0,10,2,5,7,8,6,2,10,0,7,3,7,7,3,8,1,7,1,4,6,1,2,3,10,11,2}

    {6,10,10,7,6,8,1,11,11,6,5,10,6,4,5,3,3,2,10,7,7,9,0,2,10,2,3,9,11,11,1,1,2,1,1,1,3,6,9,9,3,4,9,6,5,0,2,8,2,8,0,7,8,10}

    {2,17073,34204,73274,11098,10,4,8,2,10,70122,57735,3,2,7,9,10,3,6,4,7,5,10,9,8,6,6,8,18328,99442,13020,72600,36669,22996,70142,2,9,5,10,20999,5,2,9,51106,9,60708,8,10,8,68867,5,6,6,3}

    Returns: 28226

  26. 12

    {3,10,4,7,5,11,9,4,11,2,10,9,8,6,10,5,3,9,8,6,5,0,11,6,3,9,5}

    {1,1,6,6,2,7,3,2,2,0,3,2,10,1,9,11,9,0,7,0,3,11,6,4,10,8,7}

    {1643,7,9,3,58972,7,84647,34308,12605,73484,6,7,7,5869,3,74447,2,1,12952,10,6,8,21892,1448,77876,76262,7}

    Returns: -1

  27. 12

    {9,9,11,7,5,7,2,10,7,5,2,11,3,11,5,11,11,10,1,3,6,2,9,9,5,2,0,8,3,9,8,5,6,3,2,10,0,7,4,8,1,11,5,10,11,4,0,10,11,6,7,7,2,2,4,3,10,10,5,4,10,3,1,8,5,7,0,4,7,6,11,9}

    {8,1,3,3,9,6,8,5,9,8,11,4,7,0,7,5,10,6,9,10,2,1,0,4,2,9,4,10,6,3,2,3,3,2,0,3,8,10,1,6,8,1,0,8,7,6,2,2,9,8,5,8,4,3,8,4,11,1,6,7,9,5,0,9,4,4,10,9,11,7,6,11}

    {94420,92,25057,96129,4101,80666,49926,42434,53784,92453,87,14076,56797,17533,35171,998,27363,94826,53270,35333,16628,63947,92344,73372,35782,6183,34565,47852,12821,50784,69,50446,53790,87475,71924,53240,73,84399,58915,98909,35453,85665,5949,31462,34991,22,12,71,20742,51706,35367,37620,95,50350,35651,42706,45091,79977,17891,70027,30904,60143,33294,81,14198,61772,28295,51043,14993,35182,48,26390}

    Returns: 149380

  28. 12

    {10,7,4,8,10,0,1,6,2,3,11,6,10,9,8,9,9,0,8,3,6,2,6,8,1,4,10,5,1,5,11,8,4,11,4,5,0,0,9,11,4,7,1,1,0,9,1,10,9,3,7,3,4,3,1,7,5,0,2,3,2,3,11,8,5,8,0,3,0,9,1,6,5,5,5,0,10,7,11,11,9,10,2,1,1,4,2,0,9,7,8,9,10,3,8,11,9,4,5,10,11,2,0,2,1,10,7,11,7,7,6,6,6,11,7,4,6,8,5,3,7,6,4,8,2,4,6,5,2,3,2,10}

    {11,0,0,9,1,8,4,10,1,11,3,9,7,10,2,11,8,10,7,10,8,6,1,4,9,8,5,2,2,6,1,1,3,6,5,4,9,2,7,8,6,4,3,0,5,1,6,2,5,0,5,5,10,7,8,2,3,3,0,6,9,1,0,3,7,5,4,8,6,3,7,3,8,11,1,7,8,9,4,7,4,3,11,10,5,1,3,11,2,3,11,6,6,9,0,9,0,7,9,0,10,5,1,10,11,9,8,5,1,10,5,7,11,2,11,11,4,10,10,2,6,2,9,6,4,2,0,0,8,4,7,4}

    {4,66695,65,52,77,40,56,25,52,10,65981,86,34901,79117,20,53733,82978,77,44,26,84614,17,44,77,98,44,36451,54808,93,36,88,8661,100,45152,31774,66,81,93372,42,52729,39244,97,46,60,71,44740,24,46,46,67838,42494,26715,5,30,4,56,22156,13,14,99,26073,11,84,39685,99,63,88,88439,33,35,44451,10,54,62,60693,60,74132,43,82,52552,3539,59911,50,85391,79,92149,94,36,93,39523,8,10,90,36,53,71,84,74,75,21149,67996,84943,96975,100,79,89,58,14,58,73,33824,96553,30,52759,32,92252,56,76,4,15,31,66634,50,10,26,93,70324,57305,100,28,72,25}

    Returns: 237

  29. 12

    {11,6,0,7,11,1,9,7,8,8,5,9,3,10,3,1,2,6,11,11,4,1,0,3,2,6,0,11,8,4,0,1,2,3,10,10,9,3,11,11,9,3,5,11,8,5,6,7,3,0,5,6,6,8,7,4,5,3,8,1,0,2,4,7,4,0,6,10,9,9,8,10,3,4,0,2,7,3,6,3,11,4,8,0,9}

    {7,10,8,2,0,11,7,1,1,3,9,2,8,6,7,4,0,4,8,2,3,10,1,9,4,2,5,3,11,11,9,8,9,0,9,1,0,10,9,5,3,4,8,10,0,6,7,3,6,4,1,3,11,2,9,7,4,11,6,0,6,11,8,10,10,2,5,2,6,11,10,3,2,1,11,10,4,5,1,1,6,9,4,7,4}

    {19,30,29718,45,27,4453,30,53235,28,76,21854,68230,87884,39589,86735,78890,74841,95159,80047,36,62949,50,12,51931,57517,437,84677,1253,57382,19,14764,34,13688,9609,77335,1340,13,95,34400,66,38072,42,48883,82449,53,388,94,36666,29357,91,4560,23756,41753,57,85892,83220,87049,72471,76473,70,27328,67022,41457,45665,54739,11801,85494,7176,25057,66,69639,92709,93,1347,2,49513,12183,1937,52568,6291,41775,40,49,56464,1013}

    Returns: 15762

  30. 12

    {0,0,1,3,11,11,9,7,1,2,0,0,10,2,6,8,7,7,9,6,4,2,7,7,11,11,8,11,8,8,9,8,9,4,10,8,11,11,1,7,6,0,8,3,2,3,3,2,0,5,6,11,3,5,0,4,8,5,10,2,4,2,9,2,10,4,4,1,0}

    {1,8,11,5,10,0,1,4,8,4,6,11,6,9,9,10,1,11,4,0,2,5,6,0,1,9,2,6,0,11,5,9,3,0,8,1,4,3,6,8,3,2,4,6,0,1,0,7,5,6,5,2,7,8,7,1,5,3,7,10,7,6,10,1,3,10,9,5,9}

    {98,98,72,93403,55567,66,15,44,68948,45,38804,63894,70,57,64,32,34991,95882,3491,34688,97922,29696,31584,74,74,46285,66708,41,69,27528,67,30,54,50,69,80679,90,55,89,47,14,65666,59,23,75,6326,27,14,4,12,23135,38,3,19,27,98,80,16,48,4361,99408,6,39,95,98,53,55030,25,34}

    Returns: 375

  31. 12

    {10,6,3,9,3,10,7,4,2,5,0,4,11,7,1,7,11,11,9,9,2,11,2,6,2,0,6,0,4}

    {4,8,0,5,7,6,8,3,10,9,7,6,0,2,2,5,4,9,4,10,5,3,4,9,11,9,0,8,2}

    {35933,29545,77180,77563,82724,844,68620,2547,78012,55472,10805,53874,54188,33167,5379,24860,7723,13212,23538,92903,53484,13535,83229,33888,25471,47356,92673,996,9383}

    Returns: -1

  32. 4

    {3,1,0,1,3,2,0,1,3,2}

    {1,3,3,0,2,1,1,2,0,0}

    {72819,2438,42647,87910,61355,30322,10378,37329,97862,15009}

    Returns: 89180

  33. 9

    {2,2,8,0,0,1,3,7,0,8,7,5,4,6,4,0,8,0,2,2,1,3,6,8,5,3,0,1,5,7,4,4,7,7,1,3,5,8,2,3,1,5,3,3,1,3,8}

    {6,8,2,3,4,7,6,8,1,6,3,6,0,2,6,2,4,5,3,7,0,4,7,1,4,0,6,8,1,0,3,2,6,2,3,5,3,3,1,7,2,8,8,2,5,1,7}

    {5,38,57147,60574,47306,23,77291,40278,27,39217,14,15,3546,94008,84379,2384,37278,32012,96764,42,12611,94,32,41031,73,52832,10,94662,73205,79,32202,91,54,46598,89029,87,27,79356,74,93034,18,10,7,8699,78,34221,51}

    Returns: 457

  34. 3

    {1,2}

    {2,0}

    {61,26}

    Returns: -1

  35. 6

    {0,4,4}

    {4,1,2}

    {13,4,65}

    Returns: -1

  36. 7

    {2,3,1,0,6,4,2,1,1,6,4,0,3,5,4,2,4,1,4,5,3,3,3,5,0,0,4,5,3,5,2,0,1,1,2,6,2,5,6,6,6,0}

    {3,4,0,2,0,5,1,2,5,4,2,1,6,3,6,0,1,4,3,1,0,1,2,2,6,5,0,0,5,6,4,4,3,6,5,5,6,4,3,2,1,3}

    {47,95,21,78,52,5,86,73,40,32,49,93,86,55,57,74,78,49,68,53,52,79,6238,10,37,63367,11,87,19,47,57,3,94,91,83,97,62,66,94,78,33,36}

    Returns: 185

  37. 9

    {2,2,0,7,0,6,7,1,4,4,0,3,8,1,0,1,2,8,0,5,3,3,4,7,1,3,2,4,5,1,7,1,6,6,6,6,6,2,3,0,1,6,8,4,0,8,7,7,8,4,5,7,2}

    {7,8,2,6,3,7,4,6,2,7,8,5,1,3,7,5,1,7,1,7,2,7,6,8,8,6,0,5,4,7,5,2,2,1,3,8,4,4,0,5,0,0,4,3,4,6,0,3,5,8,0,1,3}

    {38,89,50,49,20,54,56816,40,91,100,30,56,30,98,18,49,70,18,60,74,19,34,6,17,26,61732,43318,56,10,5,82,98,36,56,95,52,72,27,40,94,98,14,70,75,48,89,63,98,65421,29718,94,57,2}

    Returns: 201

  38. 1

    {}

    {}

    {}

    Returns: 0

  39. 7

    {4,6,4,0,2,3,6,5,6,0,4,1,1,6,0,3,5,5,3,2,5,1,3,1,1,2}

    {0,3,6,5,5,5,2,0,4,6,5,0,5,1,3,4,4,2,0,6,6,4,6,3,2,0}

    {12,4,56,45,46,20,63,13,95,62,94900,24,72015,1081,43,96,88369,23,3,57280,47,33338,87,17,63,81}

    Returns: 1367

  40. 11

    {7,4,2,2,9,8,6,2,8,5,7,0,9,7,6,8,0,10,4,3}

    {9,0,5,9,5,0,7,10,3,3,1,3,1,6,4,4,5,6,10,7}

    {35082,21108,2,63037,11,95740,22034,92446,5,84427,70880,36513,86541,93421,37,26779,26196,1201,58307,99}

    Returns: -1

  41. 2

    {0}

    {1}

    {8422}

    Returns: -1

  42. 2

    {0,1}

    {1,0}

    {1,2}

    Returns: 3

  43. 1

    {}

    {}

    {}

    Returns: 0

  44. 3

    {0,0,1,2,2,1}

    {1,2,0,0,1,2}

    {17070,52578,23182,72,30143,86}

    Returns: 17228

  45. 4

    {2,0,3,1,0,1,2,1,0,3,3,2}

    {3,2,1,3,3,2,1,0,1,2,0,0}

    {22,97,47,49,43,74,87843,41,5,68,23926,60}

    Returns: 182

  46. 5

    {1,4,4,1,1,3,0,2,2,0,3,4,3,1,0,2,0,2,3}

    {0,2,0,2,3,2,4,4,3,1,4,1,0,4,3,0,2,1,1}

    {39,27,98340,61880,26,60,91,86,67,2840,30,82,43,57,97,6166,25953,2,66}

    Returns: 189

  47. 12

    {10,1,3,11,0,2,8,1,3,8,0,7,3,5,1,0,1,7,0,8,6,4,8,5,6,0,2,4,10,8,7,3,2,0,5,10,9,6,2,9,11,2,1,6,3,4,8,4,0,10,4,2,7,2,3,5,0,10,7,10,3,5,6,10,11,9,10,10,3,4,2,7,11,9,6,11,4,11,5,8,7}

    {1,6,1,4,9,6,6,10,4,5,2,8,2,7,4,6,7,10,4,9,10,2,0,3,1,3,4,10,3,2,6,6,9,7,0,4,10,5,5,7,10,10,9,9,7,11,7,8,8,8,7,11,4,8,8,1,5,5,9,7,10,6,2,11,3,4,0,6,9,1,7,5,0,8,8,7,9,5,2,3,2}

    {98344,47034,52,93453,48935,55449,23110,75389,21524,48769,14415,63116,17,50024,9609,54829,17906,18935,20,60027,89459,92985,9023,29529,63,63655,82800,53526,46878,9764,99775,81366,14192,27309,3373,84899,97085,80,52613,60112,56439,36812,37012,31881,56713,93685,49826,22972,88269,11126,50659,3098,72861,19408,31032,90778,78628,41709,61,44120,28683,72,9340,68712,88105,70887,65299,55188,94786,43,86115,38264,83131,11075,12415,59767,1139,42010,23,9132,92}

    Returns: 116931

  48. 4

    {2,2,0,3}

    {1,0,1,2}

    {31,80802,16,38605}

    Returns: -1

  49. 12

    {6,9,4,9,4,1,4,8,8,10,10,11,6,7,10,5,7,5,7,7,11,2,0,10,4,11,7,10,3,7,7,3,9,4,1,6,10,5,5,8,8,0,5,3,5,9,8,11,5,6,7,1,11,6,8,9,5,2,10,5,0,4,2,8,6,1,2,9,4,7,7,7,6,10,10,11,9,4,0,3,3,6,4,9,2,10,3,1,6,0,3,6,2,8,11,10,1,1,2,1,2,3,4,11,1,9,8,3,0,5,0,9,8,0,2,0,11,3,6,11,2,5}

    {7,0,9,10,0,0,6,11,9,1,6,3,1,11,7,7,8,4,4,6,10,6,5,2,11,4,3,4,11,9,5,5,11,1,2,4,8,10,3,2,6,9,11,0,6,8,3,1,1,11,2,5,9,8,5,5,0,4,9,9,2,7,5,0,10,6,3,6,5,0,10,1,9,5,3,2,1,3,4,2,4,2,8,4,8,11,9,9,5,6,10,3,9,1,0,0,11,4,7,7,10,6,10,6,10,2,10,1,7,2,3,7,7,8,1,10,8,7,0,5,0,8}

    {67733,92086,55051,18307,20,4449,39078,26980,16249,55,34342,91,48269,59468,34527,70161,69,44728,33364,72888,22360,9320,98361,76191,30523,50014,34138,30634,74522,64295,73888,69656,6,89062,75046,18282,16176,56387,46845,48198,7,69477,23497,21134,99,38697,6,72786,9213,71,95,13964,28,27961,46752,54527,86521,94406,41925,53365,55972,82956,55655,53196,93521,64162,52720,87,53900,60546,39428,44493,48,6034,65569,59051,10052,42968,39024,70132,77767,85544,49512,67,44431,54114,48119,28692,36,3199,5,48351,7389,80060,23623,1657,97085,28494,13265,38726,14604,15861,8061,73769,61052,17747,56815,17559,69352,98041,29300,41343,19,29,11195,17110,12855,60796,6670,8119,60,14782}

    Returns: 5029

  50. 9

    {1,3,5,1,3,8,8,5,2,0,1,7,4,7,3,2,8,6,4,8,3,2,7,4,2}

    {7,2,3,2,8,5,1,8,8,2,4,1,0,0,5,6,3,8,2,6,1,5,8,8,4}

    {52226,39706,10636,59511,64157,48287,38356,31889,8597,7438,74136,18028,40107,30794,96745,48791,93575,8505,80347,48436,31734,91772,27628,43877,32332}

    Returns: 310850

  51. 11

    {1,10,4,2,4,10,3,10,3,2,8,2,8,4,7,6,6,4,1,3,0,9,5,9,10,2,1,6,5,1,10,7,3,3,6,7,4,6,6,8,7,8,5,6,2,8}

    {0,7,8,0,6,9,9,0,7,1,5,3,9,9,10,2,7,0,2,1,1,5,9,3,6,4,9,9,3,5,5,9,6,4,0,5,1,3,8,4,0,1,10,5,6,2}

    {8049,64153,19872,87,41618,27030,55,58226,32,90,67,1417,4,51,98571,68177,50,46246,28,98,35,88,98,5434,70669,70209,23,73,25,57,20192,69,37,95,94,64095,100,75,79,49,27301,28,25151,8,57753,27519}

    Returns: 45974

  52. 9

    {0,2,4,5,4,5,1,0,5,4,3,1,7,3,6,3,6,5,0,6,8,1,0,7,8,1,6,4,8,8,1,8,2,5,6,5,2,8,2,0,3,2,8,5,0,7}

    {8,5,2,4,1,1,3,6,7,6,8,0,3,5,1,6,0,0,5,7,5,5,3,8,2,7,8,5,0,1,8,3,7,6,2,8,8,6,4,4,1,0,7,2,7,0}

    {82131,38077,60231,79878,38556,49213,91282,72989,29407,37545,96891,39902,16889,89227,93569,99066,6819,26473,42377,86759,45551,60201,80730,62926,42400,34560,64711,31738,49637,10511,88843,38994,30606,72048,92331,57706,10283,53809,55465,49245,78100,5800,38535,11986,68651,20038}

    Returns: 271097

  53. 12

    {0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11}

    {1,2,3,4,5,6,7,8,9,10,11,0,0,0,0,0,0,0,0,0,0,0}

    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}

    Returns: 22


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: