Statistics

Problem Statement for "Fences"

Problem Statement

Note to plugin users: This problem statement contains images.

Farmer John has several pastures, each of which can be described as several overlapping and/or touching rectangles. For instance, the pasture in the picture below can be considered as the union of the rectangles (2,2)-(10,5) and (7,1)-(9,7). Two rectangles that only touch each other in a corner aren't counted as touching or overlapping rectangles, see example 4.


Farmer John wants to enclose all his pastures with fences (one fence for each pasture). Help him find out the total length of all fences if all the borderlines must be fenced (see example 2).

Create a class Fences containing the method fenceLength that takes a int[] x1, a int[] y1, a int[] x2 and a int[] y2, describing the rectangles that make up the pastures by overlapping and/or touching, and returns an int, the total length of all fences. Element i in x1, y1, x2 and y2 describe one rectangle with the opposite corners x1,y1 and x2,y2.

Definition

Class:
Fences
Method:
fenceLength
Parameters:
int[], int[], int[], int[]
Returns:
int
Method signature:
int fenceLength(int[] x1, int[] y1, int[] x2, int[] y2)
(be sure your method is public)

Constraints

  • x1, y1, x2 and y2 will contain between 1 and 50 elements, inclusive.
  • x1, y1, x2 and y2 will all contain the same number of elements.
  • Each element in x1, y1, x2 and y2 will be between 0 and 1000, inclusive.
  • Element i in x1 will differ from element i in x2.
  • Element i in y1 will differ from element i in y2.

Examples

  1. {0,3,5,15}

    {0,3,7,4}

    {7,5,10,20}

    {5,8,9,8}

    Returns: 60

    Here we have four rectangles that together describes two pastures, as rectangles 0 and 1 intersect and rectangles 1 and 2 touch each other.

  2. {100,80}

    {200,230}

    {50,90}

    {250,205}

    Returns: 200

    x2 and y2 might be greater than x1 and y1.

  3. {10,30,20,10}

    {10,10,10,40}

    {20,40,40,30}

    {40,40,20,30}

    Returns: 160

    These four rectangles form a single pasture with a hole in the middle. Since there must be fences along the borders, there must both be an "outer" fence (length 120) and an "inner" fence (length 40).

  4. {976,823,228,463,702,515,690,252,153, 525,260,356,435,369,942, 59,605,173, 178, 70,420, 40,705, 38,841,430,965, 312,680,188,982,160,395,219,340,225}

    {314,759, 67,232,815,882,211,839, 48, 531,567,803,439,418,968, 74, 88,834, 806,920,920,194,602,436,624,331,314, 68,421,659,653, 99,921,339,865,408}

    {835,794,980, 90,808,649,198,334,309, 749,187,965,578,199,655,273,503,489, 167,996,212,355, 34,430,749,527,109, 501,380, 36,641,872, 47,157,433, 85}

    {306,421,283,413,466,747,882,297,790, 576,695,102,655,121, 82,400, 36,236, 143,108,862,400,357,386,790,732, 4, 800,316,166,239,242,121, 57,111, 85}

    Returns: 3854

  5. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    {1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000}

    {1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000}

    Returns: 4000

  6. {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,49}

    {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,49}

    {951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000}

    {1000,999,998,997,996,995,994,993,992,991,990,989,988,987,986,985,984,983,982,981,980,979,978,977,976,975,974,973,972,971,970,969,968,967,966,965,964,963,962,961,960,959,958,957,956,955,954,953,952,951}

    Returns: 4000

  7. {294,349,592,530,239,487,433,436,905,991,780}

    {531,775,125,701,180,737,452,163,477,378,27}

    {504,466,358,250,621,172,258,792,931,120,437}

    {506,940,287,283,120,602,11,277,423,669,450}

    Returns: 4006

  8. {540,632,74,207,948,594,725,882,200,807,135,135,438,489,731,158,669,856,255,495,658,225,742,724,545,564,28,398,420,736,28,406,231,956,770,919,897,5}

    {274,549,772,566,677,524,287,35,680,497,868,575,598,375,21,756,202,645,169,729,726,226,125,763,662,651,741,294,840,666,877,694,769,332,925,479,766,541}

    {928,583,393,14,370,100,161,674,135,512,835,283,778,628,302,552,559,157,565,48,940,488,691,719,292,226,53,284,210,485,983,961,333,266,685,236,721,873}

    {960,13,746,127,761,211,206,157,862,419,194,186,179,544,788,988,886,84,785,197,978,438,456,932,778,606,106,846,102,123,216,904,754,20,130,914,985,584}

    Returns: 3998

  9. {714,383,694,146,216,514,647,256,845}

    {953,936,585,878,748,499,201,541,916}

    {754,321,44,190,352,485,642,959,579}

    {469,431,713,564,382,137,999,826,701}

    Returns: 5336

  10. {265,115,642,771,864,282,313,475,492,698,49,144,714,418,42,832,622,973,923,858,312,968,901,292,303,181,611,12,845,704,350,511,49,571,944,935,590,561,777,280,816,476,766,479,837,97,49,733,668}

    {801,321,987,929,793,577,227,833,728,811,193,3,611,298,351,503,932,639,43,402,3,695,371,693,404,719,590,705,99,74,266,651,703,817,104,996,822,359,662,241,242,147,611,824,700,431,710,31,691}

    {697,347,330,689,132,699,342,450,947,642,594,844,383,877,353,165,868,603,628,734,472,65,715,757,42,986,609,786,322,1000,369,791,202,535,357,182,18,142,124,113,23,661,904,626,614,409,827,885,878}

    {181,930,948,216,487,859,15,311,88,182,21,241,186,220,181,126,791,285,36,758,562,980,228,386,900,930,855,232,598,338,3,431,458,137,22,374,879,747,515,25,75,827,388,544,945,996,991,731,666}

    Returns: 4088

  11. {591,378,428,401,237,913,94,82,37,253,53,259,836,110,609,141,744,795,775,338,463,530,387}

    {3,880,824,93,356,178,257,797,214,736,978,820,703,607,756,702,228,430,96,870,407,525,283}

    {323,387,908,84,380,403,40,52,723,20,405,258,283,845,748,570,84,240,410,926,546,312,974}

    {928,89,388,285,867,201,432,589,573,773,627,261,501,221,48,168,211,633,654,698,400,310,296}

    Returns: 4676

  12. {504,863,898}

    {677,121,119}

    {462,912,931}

    {912,945,51}

    Returns: 2502

  13. {501,479,586,562,399,172,247,599,244,74,517,904}

    {295,890,655,281,833,99,218,194,417,879,243,515}

    {884,445,433,245,552,630,597,568,520,500,297,298}

    {91,201,707,860,901,5,247,966,473,265,331,514}

    Returns: 6074

  14. {657,238,694,6,911,804,261,293,992,184,8,640,513}

    {994,609,968,992,855,209,540,764,437,759,775,617,809}

    {1,160,648,932,407,7,211,860,796,596,496,835,881}

    {214,902,971,4,412,432,402,211,272,934,149,203,962}

    Returns: 3962

  15. {247,240,199,903,320,101,255,487,883,702,970,61,858,379,173,664,538,560,387,714,466,766,120,131,328,377,11,993,981,728,70,629,451,518,568,339,842,136,88,721,787,234}

    {507,2,51,64,866,793,241,146,914,708,545,497,230,786,618,832,866,438,280,309,558,88,586,113,635,45,434,666,480,206,223,545,931,664,392,881,244,840,596,713,961,491}

    {805,504,872,560,406,993,942,476,226,189,175,702,848,869,663,75,453,258,767,308,667,687,721,584,339,288,160,44,679,310,464,521,718,357,317,632,196,945,304,172,309,428}

    {302,175,699,221,627,920,684,622,882,295,288,738,26,666,822,499,461,887,349,625,719,215,734,14,224,946,597,885,114,328,935,52,303,846,202,535,565,566,426,428,876,750}

    Returns: 4180

  16. {439,719,445,573,326,599,654,280,804,188,96,794,433,166,704,69,458,526,395,546,933,74,402,287,407,124,282,752,809,686,52,322,583,40,866,379,374,163,382,890,874,702,506,374,837,121,551,51}

    {233,883,853,312,890,561,384,320,520,24,200,576,703,92,186,193,598,593,406,782,581,766,597,142,760,252,498,518,304,757,304,564,840,597,290,602,19,711,505,8,568,9,267,145,930,288,614,515}

    {630,248,713,745,768,12,797,709,476,863,269,556,633,462,910,95,334,594,543,746,434,416,408,56,760,519,689,444,880,684,754,981,824,32,854,646,62,187,504,501,442,452,1000,754,508,267,75,578}

    {917,802,684,715,441,75,795,833,699,750,268,850,245,942,987,792,194,750,757,611,380,49,816,6,302,491,346,595,836,920,280,851,147,222,94,296,713,594,796,469,675,219,913,163,77,913,242,645}

    Returns: 4144

  17. {595,713,548,562,562,39,375,682,210}

    {244,686,907,383,155,327,756,330,445}

    {625,607,103,146,663,845,307,946,542}

    {146,972,5,155,716,38,546,354,31}

    Returns: 5270

  18. {136,335,295,727,587,235,388,107,683,882,902,556,990}

    {638,482,469,867,920,13,873,494,62,803,11,489,551}

    {247,521,790,950,258,157,585,467,512,334,745,809,326}

    {580,511,575,875,44,470,794,187,250,769,622,797,436}

    Returns: 5854

  19. {739,230,269,924,464,184,482,394,750,468,16,41,250,968,782,827,852,715,114,241,511,431,828,595,925,411,67,287,896,553,314,774,968,519,520,903,436,888,803,893,502,324,228,238,384}

    {862,432,674,107,920,793,126,545,347,210,906,483,317,683,313,408,127,697,384,533,268,195,645,784,181,941,939,523,742,607,171,459,469,162,482,230,340,328,658,192,538,176,745,561,404}

    {327,18,20,109,75,599,552,609,963,659,223,143,290,127,462,52,271,578,667,370,731,389,919,548,364,14,407,118,794,324,170,487,417,923,990,874,775,943,428,222,654,900,880,411,515}

    {604,853,835,434,557,468,878,801,808,798,122,684,948,439,599,994,702,640,730,902,136,447,743,492,307,151,430,239,572,559,433,605,865,525,538,59,489,875,599,839,775,656,753,544,846}

    Returns: 3844

  20. {361,519,144,988,239,348,454,872,764,373,430,729,959,904,373,190,931,662,808,430,869}

    {151,956,321,509,610,556,476,970,726,783,685,171,540,713,5,754,595,88,398,341,768}

    {32,253,340,557,874,95,273,381,1,238,691,202,114,309,873,98,259,106,908,776,482}

    {512,349,856,805,496,656,500,409,130,57,29,105,670,953,333,823,691,616,486,925,779}

    Returns: 4308

  21. {809,407,273,699,87,3,895,744}

    {650,778,216,38,807,619,94,35}

    {386,761,316,666,921,793,3,872}

    {111,974,185,512,137,680,11,729}

    Returns: 5258

  22. {262,270,754,926,447,547,608,527,355,644,372,275,672,192,125,252,117,284,947,527,52}

    {120,85,454,759,986,406,412,326,426,462,612,50,232,524,485,554,836,790,399,311,963}

    {929,524,889,747,827,38,509,644,702,233,205,537,607,709,513,515,826,715,288,111,40}

    {671,306,831,773,891,491,211,114,598,140,154,413,823,885,197,732,1,647,314,440,370}

    Returns: 5626

  23. {333,883,35,989,857,35,676,935,479,148,331,624,980,775,493,292,830,244,276,806,514,11}

    {82,196,286,745,1000,924,427,246,36,135,752,108,238,600,120,671,894,477,80,378,720,356}

    {899,5,344,124,363,930,144,523,986,383,490,618,756,763,534,860,196,450,98,865,649,665}

    {76,288,343,407,859,517,725,403,163,35,167,338,333,532,804,451,281,410,73,752,392,50}

    Returns: 5120

  24. {162,254,875,18,601,387,138,906,429,705,612,162,105,882}

    {227,794,676,443,814,102,816,374,388,742,637,98,775,234}

    {170,483,737,338,462,38,216,6,378,41,481,505,711,685}

    {981,98,977,994,307,6,397,625,152,994,851,849,291,795}

    Returns: 4502

  25. {769,264,30,745,934,686,478,238,952,533,314,839}

    {19,454,338,866,141,403,159,414,118,178,127,72}

    {70,822,157,282,602,235,830,85,438,909,619,162}

    {671,42,728,478,620,616,820,417,818,725,473,51}

    Returns: 3686

  26. {40,974,910,835}

    {813,251,709,721}

    {962,929,426,849}

    {648,274,572,460}

    Returns: 2686

  27. {493,89,505,492,899,833,1000,267,796,59,149,426,261,867,611,919,930,565,699,423,990,681,522,137}

    {795,945,573,545,926,886,519,830,819,826,607,525,726,52,460,155,616,29,877,387,795,17,814,395}

    {961,60,591,301,445,945,264,174,154,764,939,825,321,250,113,710,784,886,113,280,314,832,1000,304}

    {203,243,585,21,267,329,409,644,474,34,525,362,271,367,394,569,569,838,397,336,45,423,118,117}

    Returns: 3964

  28. {749,89,202,502,758,84,834,235,45,377,934,987,214,189,570,935,471,879,685,856,989,27,709,135,926,704,326,764,957,62,29,284,843,173,557,796,550}

    {334,218,838,531,904,759,836,317,704,82,561,40,80,689,982,813,571,842,4,147,221,93,994,502,804,763,880,369,139,373,142,218,347,327,360,752,711}

    {922,43,973,108,706,236,467,185,727,910,41,132,89,941,347,729,534,166,695,686,309,362,76,670,839,866,189,129,446,138,861,467,165,295,314,498,157}

    {462,383,868,260,580,698,775,255,562,390,198,446,383,553,834,789,803,471,841,534,958,783,188,745,343,787,307,163,910,860,585,722,284,927,16,47,137}

    Returns: 3952

  29. {692,586,741,250,932,238,314,709,111,302,793,906,154,16,290,820,550,362,486,926,450,740,810,97,314,23,697}

    {676,549,210,762,967,11,461,58,290,515,784,436,198,706,753,502,686,167,165,732,890,479,198,729,665,722,434}

    {811,821,350,603,916,925,248,65,693,645,349,180,43,626,16,227,612,837,558,972,282,697,172,530,699,108,418}

    {519,619,999,809,7,640,471,510,146,277,838,156,191,564,307,570,317,622,695,974,896,743,209,533,705,772,568}

    Returns: 5134

  30. {906,85,646,687,387,422,741,909,596,25,310,133,25}

    {728,353,254,749,379,472,206,381,919,145,85,953,802}

    {86,469,372,524,805,914,5,997,873,380,950,973,641}

    {603,3,310,785,404,536,639,835,124,56,447,193,632}

    Returns: 4004

  31. {481,850,521,583,63,940,446,953}

    {763,268,846,625,748,888,333,999}

    {197,379,229,325,552,409,877,26}

    {617,200,93,999,656,679,300,477}

    Returns: 5036

  32. {579,895,938,614,826,644,568,81,363,391,935,975,337,580,466,875,614,736,771,18,377,244,199,330,540,89,502,600}

    {488,891,489,423,113,133,354,55,715,400,484,839,79,552,979,928,23,862,740,524,709,949,216,42,853,343,830,559}

    {37,303,53,196,731,454,659,966,550,632,753,697,468,756,646,212,282,585,897,803,259,514,424,85,360,546,492,29}

    {724,490,385,942,237,252,935,705,519,888,557,984,603,988,230,570,373,431,418,1,456,676,896,658,509,395,591,87}

    Returns: 4030

  33. {394,546,662,694,333,42,801,965,651,511,273,160,637,386,190,651,175,834,244,367}

    {46,639,620,149,593,111,979,506,990,356,649,660,484,730,845,716,834,616,105,664}

    {635,573,259,697,645,695,364,40,232,493,427,230,80,485,769,839,921,572,974,608}

    {488,185,657,653,846,545,785,984,803,973,925,360,236,532,562,436,870,178,87,889}

    Returns: 4716

  34. {543,284,629,661,642,135,644,646,87,276,110,116,617,42,717,203,335,354,683}

    {503,991,877,418,247,475,59,602,502,793,286,739,737,761,404,377,631,396,361}

    {270,174,339,370,771,131,985,718,738,205,331,68,959,330,934,535,113,435,587}

    {801,597,786,1000,343,463,350,135,54,525,357,101,799,395,136,812,887,111,581}

    Returns: 4732

  35. {258,871,921,935,100,921,872,969,989,243,453,595,787}

    {362,322,473,326,469,961,540,972,74,861,761,366,412}

    {226,589,714,657,159,912,802,668,884,707,863,630,647}

    {609,294,854,225,549,443,971,121,870,802,127,583,663}

    Returns: 4554

  36. {768,464,14}

    {418,438,231}

    {992,180,783}

    {343,859,550}

    Returns: 3212

  37. {33,186,939,32,236,501,688,51,559,733,669,671,769,90,299,190,164,54,970,294,381,262,16,857,490,921,686,167,461,864,490,263,977,953,98,416,323,800,176}

    {70,705,298,761,116,886,399,493,498,681,158,560,133,522,384,594,23,242,836,439,440,502,834,65,424,868,488,584,90,860,21,450,617,68,609,566,50,511,807}

    {153,620,937,254,790,882,989,118,336,530,23,766,421,198,764,938,683,321,102,94,5,391,671,923,260,432,213,493,221,723,508,982,182,950,839,267,102,258,705}

    {701,337,471,54,418,88,206,116,266,919,787,889,204,743,706,490,757,105,962,407,46,845,301,601,783,827,102,215,449,159,1,689,900,244,220,203,266,629,822}

    Returns: 4620

  38. {552,968,499,103,847,521,858,232,832,119,595,143,600}

    {113,908,752,614,770,812,845,990,469,456,791,617,886}

    {203,164,641,710,577,864,201,385,748,953,12,525,853}

    {926,538,300,168,208,770,551,450,21,643,958,258,735}

    Returns: 4162

  39. {678,734,786,468,753,450,51,537,462,465,53,82,723,731,673,719,183,43,549,283,247,419,666,800,370,791,269}

    {53,703,827,241,492,975,824,498,978,981,933,456,607,833,719,988,339,588,685,939,257,748,677,161,800,791,505}

    {992,522,92,752,941,900,445,436,961,350,335,234,415,789,485,825,927,856,967,206,59,465,393,97,85,660,12}

    {891,379,924,791,437,714,637,111,833,449,804,932,665,194,517,665,683,812,651,607,135,206,409,787,264,987,311}

    Returns: 4208

  40. {824,522,640,683,649,217,884,190,632,807,415,256,436,246,977,287,50,935,325,488,709,773,749,909,936,932,913,749,855,596,672,526,841,520,557,748,27,552,878}

    {224,37,273,397,53,186,216,429,87,298,496,369,309,904,276,472,960,901,291,406,583,336,277,487,264,344,977,768,21,23,937,931,875,427,365,509,795,793,978}

    {95,907,464,665,110,809,455,80,234,93,112,176,438,143,49,681,792,292,511,922,896,517,321,529,450,659,364,423,912,949,754,388,162,734,469,641,972,568,503}

    {998,117,128,903,133,218,723,680,10,83,692,348,387,16,960,890,714,376,310,688,426,212,645,794,842,601,109,571,723,22,843,354,503,90,3,29,1000,132,986}

    Returns: 4460

  41. {987,229,381,712,975,316,605,244,367,222,337,676,101,244,21,969,281,101,118,747,515,665,733,952,433,639,878,18,927,644,707,73,758,169,891,255,120}

    {694,604,449,380,779,255,118,659,269,119,299,875,735,867,374,8,253,915,717,84,141,666,391,86,940,133,608,362,504,721,408,24,971,144,371,231,285}

    {255,436,185,909,611,321,613,170,362,453,267,233,71,270,403,770,57,944,723,630,551,853,99,683,994,862,58,90,535,717,601,757,842,350,629,467,936}

    {27,60,471,597,902,490,116,443,890,917,323,675,126,373,693,168,566,243,389,916,350,67,218,519,710,164,438,525,949,327,535,634,984,645,785,496,575}

    Returns: 4120

  42. {546,329,352,302,54,404,344,530,893,639,563,1000,793,265,940,227,399}

    {963,830,542,564,554,284,988,36,383,719,97,530,378,457,775,278,712}

    {651,231,151,107,425,394,251,176,66,145,363,725,410,639,963,50,688}

    {863,665,597,731,713,385,863,923,622,770,384,802,874,242,118,445,186}

    Returns: 4830

  43. {869,683,623,165,164,521,691,987,908,372}

    {642,393,454,693,284,256,914,347,905,2}

    {389,169,809,993,416,758,797,696,392,455}

    {575,819,604,355,225,900,123,709,68,97}

    Returns: 3976

  44. {932,206,458,557,987,760,337,599,170,969,97,95,346,156,179,110,621,210,862,868,162,577,486,359,608,147}

    {461,205,582,264,749,709,321,230,902,716,829,776,907,513,337,434,101,959,143,564,265,880,174,225,678,64}

    {212,988,352,816,894,125,607,738,572,533,427,491,174,47,338,751,115,775,792,909,625,857,813,247,165,377}

    {630,511,868,429,980,263,675,749,638,912,98,110,677,182,207,970,275,437,935,167,307,170,943,468,627,910}

    Returns: 4210

  45. {290,514,651,868,657,931,202,642,742,665,869,659,129,764,354,950,673,943,517,9,613,745,824,125,974,689}

    {685,316,694,902,358,697,825,427,697,0,168,442,350,695,80,698,809,602,879,671,280,64,380,719,252,464}

    {230,468,444,581,483,622,829,854,920,297,781,72,165,528,492,122,532,578,492,158,522,378,411,600,6,109}

    {615,673,820,432,111,82,426,55,539,759,880,388,744,613,198,90,681,186,526,480,369,177,67,318,342,888}

    Returns: 4066

  46. {593,476,86,978,238,664,560,171,337,548,736,776,509,827,328,337,50,273,636,403,103,329,407}

    {187,182,119,742,475,557,585,834,69,147,243,57,983,374,565,282,474,502,399,236,323,452,471}

    {233,722,121,660,944,594,81,85,807,904,802,371,581,558,713,732,836,881,220,430,902,970,913}

    {998,618,726,627,982,801,171,225,120,971,22,622,325,774,516,180,614,105,451,724,241,746,598}

    Returns: 4352

  47. {606,476,441,302,282,908,133}

    {153,725,212,573,381,619,71}

    {97,413,238,120,595,764,167}

    {214,232,892,978,409,380,145}

    Returns: 4194

  48. {473,785,50,709,61,353,438,911,433,975,737,494,884,878,540,347,442,797,628,977,359,169,286,390,455,303,205,736,423,82,622,384,755,838,977,570,395,270,356}

    {36,958,844,398,538,437,704,45,694,748,126,783,942,318,99,387,184,27,405,964,592,50,486,344,32,469,773,295,591,531,734,621,616,522,866,26,875,419,38}

    {756,641,658,274,900,82,397,0,653,345,792,509,31,793,150,844,179,916,528,249,391,434,806,731,195,833,691,368,434,791,743,389,717,877,492,913,793,735,230}

    {474,320,791,796,994,102,461,213,742,734,804,118,435,46,68,505,923,130,787,397,100,386,582,752,145,400,611,584,460,478,272,393,694,208,614,342,245,496,361}

    Returns: 4402

  49. {841,732,727,494,159,631,307,139,158,380,286,628,124,225,933,23,266,401,48,538,552,725,272,969,421,106,955,782,443,563,969,84,19,721,82,871,477,991,224,840,79,724,657,204,232,102,527,329,12,950}

    {635,845,520,500,590,833,209,641,961,643,13,61,695,904,899,140,806,718,154,182,699,193,450,241,321,361,250,452,914,491,957,989,155,136,860,421,46,493,33,869,868,860,135,175,54,286,539,825,352,228}

    {637,551,122,309,777,46,681,147,530,864,606,147,540,468,24,647,577,702,686,539,312,35,430,525,955,50,674,655,388,223,607,725,173,778,386,501,113,269,822,545,374,552,821,513,33,428,821,151,962,132}

    {253,591,185,150,726,965,0,995,701,836,261,366,436,64,959,718,603,42,417,918,285,436,330,915,144,621,260,37,655,864,306,805,469,984,176,948,741,609,892,53,138,848,133,609,41,526,495,926,881,177}

    Returns: 4152

  50. {568,162,595,6,166,86,931,459,784,681,966,42,725,923,259,713,185}

    {321,998,484,842,292,241,461,435,271,425,854,192,641,773,167,790,168}

    {630,738,143,8,345,994,459,26,384,375,384,82,642,880,749,569,237}

    {517,228,6,181,296,535,579,976,706,663,37,380,855,881,24,841,543}

    Returns: 5756

  51. {959,512,908,962,401,894,248,34,271,872,211,530,259,674,802,428,867,466,375,721,863,221,198,204,247,60,132,906,843,579,976,537,669,524,582,544,196,263,242,656,783,970,676,140,960,17,640,30,688}

    {937,122,224,584,803,250,835,994,586,256,536,164,879,771,463,673,717,680,645,877,212,489,778,281,676,761,290,765,121,698,399,517,323,521,213,195,672,336,181,636,92,744,856,871,21,283,72,873,423}

    {437,617,195,508,754,334,424,973,744,95,303,129,598,231,283,108,687,200,654,243,105,17,943,116,189,966,323,7,445,654,319,397,373,488,204,342,568,127,476,912,849,289,0,244,264,710,859,226,402}

    {910,130,740,260,35,832,867,732,301,606,976,194,637,500,618,213,623,811,614,832,939,331,787,197,152,111,918,422,432,624,641,521,508,219,446,975,553,139,102,132,107,438,194,530,970,672,785,406,955}

    Returns: 3904

  52. {884,516,342,532,229,905,724,77,232,397,979,655,871,979}

    {185,739,776,402,89,884,879,735,151,740,527,495,62,374}

    {698,317,245,224,717,678,134,356,594,129,882,31,376,417}

    {451,15,627,87,941,263,34,812,113,616,237,138,88,758}

    Returns: 4156

  53. {606,423,999,1000,484,584,922,752,440,658,31,504,830}

    {934,402,261,160,424,189,953,567,847,468,326,79,140}

    {527,881,826,358,444,693,20,988,798,931,784,732,360}

    {249,721,126,795,27,671,818,546,83,344,765,652,465}

    Returns: 4914

  54. {631,649,864,731,27,879,108,742,69}

    {503,939,285,61,1000,515,865,755,598}

    {332,182,686,946,208,943,891,649,49}

    {131,653,765,242,610,287,227,493,364}

    Returns: 4520

  55. {756,978,887,11,204,691,370,295,621,246,183,886,483,757}

    {10,35,152,213,43,721,832,535,681,340,798,285,895,849}

    {739,836,700,356,955,584,821,141,255,794,175,680,175,693}

    {871,237,596,786,316,955,346,630,457,480,382,911,589,906}

    Returns: 4662

  56. {684,189,311,662,263,162,506,457,604,1000,843,457,818,28,725,646,883,646,351,972,628,896,753,418,989,261,190}

    {988,426,646,255,297,935,460,169,199,270,199,635,171,668,341,849,652,346,511,38,940,668,532,142,257,793,222}

    {445,8,547,838,314,374,939,910,642,697,776,432,271,855,876,224,29,821,94,461,325,764,437,38,635,341,247}

    {839,131,774,173,583,112,970,982,429,741,754,604,710,438,119,91,844,547,607,799,958,866,857,259,612,800,535}

    Returns: 4564

  57. {1,5}

    {1,5}

    {5,10}

    {5,10}

    Returns: 36

    The two rectangles only touch each other at one corner, and are thus considered as different pastures.


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: