day 5
This commit is contained in:
parent
cfeb794e91
commit
f0f10a53e5
|
@ -0,0 +1,43 @@
|
|||
import sys
|
||||
|
||||
W = 1000
|
||||
H = 1500
|
||||
|
||||
grid = [ [ 0 for _ in range(W) ] for _ in range(H) ]
|
||||
|
||||
#print(grid)
|
||||
|
||||
L = eval(sys.stdin.read())
|
||||
|
||||
#print(L)
|
||||
def printgrid():
|
||||
for row in grid:
|
||||
print("".join(map(str,row)))
|
||||
|
||||
printgrid()
|
||||
|
||||
v=0
|
||||
h=0
|
||||
n=0
|
||||
for ((x1,y1),(x2,y2)) in L:
|
||||
print((x1,y1),(x2,y2))
|
||||
if x1 == x2:
|
||||
v+=1
|
||||
(y1, y2) = (min(y1,y2), max(y1,y2))
|
||||
for y in range(y1, y2+1):
|
||||
grid[x1][y]+=1
|
||||
if grid[x1][y]==2:
|
||||
n+=1
|
||||
elif y1 == y2:
|
||||
h+=1
|
||||
(x1, x2) = (min(x1,x2), max(x1,x2))
|
||||
for x in range(x1, x2+1):
|
||||
grid[x][y1]+=1
|
||||
if grid[x][y1]==2:
|
||||
n+=1
|
||||
|
||||
printgrid()
|
||||
|
||||
print(n, v, h, v+h)
|
||||
|
||||
# 1116 too low
|
|
@ -0,0 +1,25 @@
|
|||
import sys
|
||||
W,H = 1000,1000
|
||||
grid = [ [ 0 for _ in range(W) ] for _ in range(H) ]
|
||||
L = eval(sys.stdin.read())
|
||||
sign = lambda x: (1, -1)[x<0]
|
||||
n=0
|
||||
def incr(x,y):
|
||||
global n
|
||||
grid[x][y]+=1
|
||||
if grid[x][y]==2:
|
||||
n+=1
|
||||
for ((x1,y1),(x2,y2)) in L:
|
||||
if x1 == x2:
|
||||
for y in range(min(y1,y2), max(y1,y2)+1):
|
||||
incr(x1,y)
|
||||
elif y1 == y2:
|
||||
for x in range(min(x1,x2), max(x1,x2)+1):
|
||||
incr(x,y1)
|
||||
else:
|
||||
r = abs(x1-x2)
|
||||
i = sign(x2-x1)
|
||||
j = sign(y2-y1)
|
||||
for a in range(r+1):
|
||||
incr(x1+a*i,y1+a*j)
|
||||
print(n)
|
|
@ -0,0 +1,502 @@
|
|||
[
|
||||
((194,556),(739,556)),
|
||||
((818,920),(818,524)),
|
||||
((340,734),(774,300)),
|
||||
((223,511),(146,434)),
|
||||
((841,47),(122,766)),
|
||||
((323,858),(859,322)),
|
||||
((277,205),(85,205)),
|
||||
((782,901),(782,186)),
|
||||
((969,96),(969,648)),
|
||||
((504,971),(989,971)),
|
||||
((926,151),(926,480)),
|
||||
((722,895),(722,488)),
|
||||
((15,14),(987,986)),
|
||||
((378,486),(267,597)),
|
||||
((732,418),(157,418)),
|
||||
((252,515),(257,520)),
|
||||
((61,828),(659,230)),
|
||||
((116,652),(893,652)),
|
||||
((827,196),(827,564)),
|
||||
((677,515),(677,257)),
|
||||
((380,897),(132,897)),
|
||||
((812,959),(812,23)),
|
||||
((989,382),(294,382)),
|
||||
((973,89),(81,981)),
|
||||
((292,920),(987,225)),
|
||||
((441,394),(441,469)),
|
||||
((502,662),(502,213)),
|
||||
((609,570),(609,58)),
|
||||
((559,47),(208,47)),
|
||||
((77,192),(277,192)),
|
||||
((229,588),(66,588)),
|
||||
((705,363),(705,161)),
|
||||
((944,51),(78,917)),
|
||||
((699,889),(699,354)),
|
||||
((90,48),(955,913)),
|
||||
((166,491),(24,633)),
|
||||
((154,482),(113,441)),
|
||||
((989,989),(10,10)),
|
||||
((421,414),(791,44)),
|
||||
((360,272),(966,272)),
|
||||
((264,631),(630,631)),
|
||||
((541,50),(541,911)),
|
||||
((17,475),(289,203)),
|
||||
((226,772),(697,301)),
|
||||
((163,625),(163,513)),
|
||||
((642,971),(642,754)),
|
||||
((975,329),(793,329)),
|
||||
((793,878),(793,938)),
|
||||
((10,95),(175,95)),
|
||||
((352,903),(352,176)),
|
||||
((914,92),(91,915)),
|
||||
((649,768),(649,136)),
|
||||
((347,492),(347,977)),
|
||||
((372,839),(372,741)),
|
||||
((587,534),(526,534)),
|
||||
((563,936),(102,475)),
|
||||
((126,708),(362,708)),
|
||||
((326,869),(326,640)),
|
||||
((358,959),(358,408)),
|
||||
((221,99),(221,659)),
|
||||
((572,405),(906,71)),
|
||||
((592,664),(687,759)),
|
||||
((618,457),(388,687)),
|
||||
((712,850),(245,383)),
|
||||
((981,22),(45,958)),
|
||||
((107,884),(340,651)),
|
||||
((17,896),(642,896)),
|
||||
((488,135),(851,135)),
|
||||
((54,76),(184,76)),
|
||||
((290,596),(290,478)),
|
||||
((468,427),(468,316)),
|
||||
((412,434),(412,581)),
|
||||
((899,681),(238,20)),
|
||||
((647,231),(542,231)),
|
||||
((54,374),(302,622)),
|
||||
((586,555),(13,555)),
|
||||
((875,930),(26,81)),
|
||||
((875,115),(127,863)),
|
||||
((863,42),(45,860)),
|
||||
((708,862),(100,862)),
|
||||
((190,490),(26,654)),
|
||||
((347,944),(711,580)),
|
||||
((259,533),(259,516)),
|
||||
((833,790),(891,848)),
|
||||
((556,583),(921,948)),
|
||||
((745,929),(745,569)),
|
||||
((111,100),(499,100)),
|
||||
((638,903),(525,903)),
|
||||
((726,388),(973,388)),
|
||||
((335,504),(638,504)),
|
||||
((628,29),(159,29)),
|
||||
((375,406),(200,406)),
|
||||
((12,819),(945,819)),
|
||||
((660,330),(318,672)),
|
||||
((436,477),(436,988)),
|
||||
((925,41),(464,41)),
|
||||
((868,485),(868,109)),
|
||||
((130,859),(979,10)),
|
||||
((895,50),(895,568)),
|
||||
((582,943),(582,904)),
|
||||
((589,616),(589,590)),
|
||||
((773,359),(441,691)),
|
||||
((396,22),(396,730)),
|
||||
((862,947),(30,115)),
|
||||
((573,543),(40,10)),
|
||||
((726,743),(726,934)),
|
||||
((360,170),(360,187)),
|
||||
((597,287),(982,287)),
|
||||
((537,112),(838,112)),
|
||||
((702,683),(151,683)),
|
||||
((770,792),(752,792)),
|
||||
((964,60),(896,60)),
|
||||
((53,642),(278,642)),
|
||||
((414,871),(798,487)),
|
||||
((96,950),(96,983)),
|
||||
((251,65),(289,65)),
|
||||
((797,666),(797,200)),
|
||||
((582,157),(582,538)),
|
||||
((107,398),(594,885)),
|
||||
((96,66),(806,776)),
|
||||
((124,911),(347,911)),
|
||||
((974,538),(974,318)),
|
||||
((45,966),(226,785)),
|
||||
((39,960),(827,172)),
|
||||
((163,939),(709,939)),
|
||||
((351,540),(351,954)),
|
||||
((656,894),(220,458)),
|
||||
((278,314),(278,146)),
|
||||
((637,784),(637,283)),
|
||||
((83,690),(899,690)),
|
||||
((16,48),(884,916)),
|
||||
((681,865),(310,494)),
|
||||
((333,631),(333,832)),
|
||||
((527,652),(527,836)),
|
||||
((352,343),(352,623)),
|
||||
((256,316),(479,93)),
|
||||
((450,86),(489,86)),
|
||||
((814,834),(814,494)),
|
||||
((406,947),(783,947)),
|
||||
((811,643),(318,643)),
|
||||
((240,651),(366,651)),
|
||||
((902,618),(303,19)),
|
||||
((843,939),(729,939)),
|
||||
((901,149),(131,919)),
|
||||
((365,459),(222,459)),
|
||||
((909,218),(426,701)),
|
||||
((746,415),(746,199)),
|
||||
((249,327),(807,885)),
|
||||
((760,923),(860,923)),
|
||||
((506,259),(506,357)),
|
||||
((933,892),(143,892)),
|
||||
((88,589),(88,77)),
|
||||
((597,554),(810,554)),
|
||||
((505,574),(505,812)),
|
||||
((211,786),(906,91)),
|
||||
((387,238),(480,238)),
|
||||
((394,729),(422,757)),
|
||||
((526,436),(526,12)),
|
||||
((660,397),(660,290)),
|
||||
((856,469),(176,469)),
|
||||
((653,731),(370,731)),
|
||||
((542,241),(542,32)),
|
||||
((471,734),(471,384)),
|
||||
((975,468),(783,468)),
|
||||
((25,578),(580,578)),
|
||||
((52,632),(551,133)),
|
||||
((150,791),(672,791)),
|
||||
((643,348),(643,869)),
|
||||
((893,514),(893,422)),
|
||||
((400,463),(335,463)),
|
||||
((564,917),(676,917)),
|
||||
((166,433),(166,246)),
|
||||
((798,36),(69,765)),
|
||||
((118,977),(882,977)),
|
||||
((718,415),(75,415)),
|
||||
((690,807),(690,659)),
|
||||
((163,809),(269,809)),
|
||||
((715,238),(715,314)),
|
||||
((970,924),(104,58)),
|
||||
((683,762),(683,467)),
|
||||
((554,375),(980,801)),
|
||||
((361,130),(361,66)),
|
||||
((879,491),(879,843)),
|
||||
((515,700),(515,454)),
|
||||
((465,432),(465,444)),
|
||||
((250,239),(216,273)),
|
||||
((894,818),(163,818)),
|
||||
((190,790),(190,616)),
|
||||
((384,263),(384,84)),
|
||||
((63,875),(851,87)),
|
||||
((154,293),(278,417)),
|
||||
((21,592),(883,592)),
|
||||
((372,286),(588,70)),
|
||||
((972,447),(972,639)),
|
||||
((838,60),(681,60)),
|
||||
((38,366),(38,907)),
|
||||
((746,65),(459,65)),
|
||||
((138,640),(66,640)),
|
||||
((536,309),(536,109)),
|
||||
((772,634),(772,566)),
|
||||
((43,949),(945,47)),
|
||||
((914,85),(395,85)),
|
||||
((25,12),(977,964)),
|
||||
((679,455),(679,439)),
|
||||
((420,492),(614,492)),
|
||||
((823,658),(823,634)),
|
||||
((45,332),(45,943)),
|
||||
((807,344),(807,756)),
|
||||
((634,974),(634,892)),
|
||||
((26,26),(988,988)),
|
||||
((628,772),(15,772)),
|
||||
((829,614),(550,614)),
|
||||
((513,649),(513,369)),
|
||||
((607,923),(607,801)),
|
||||
((809,340),(450,699)),
|
||||
((550,193),(666,193)),
|
||||
((175,961),(902,234)),
|
||||
((467,146),(500,146)),
|
||||
((543,510),(543,626)),
|
||||
((667,52),(667,161)),
|
||||
((635,299),(375,299)),
|
||||
((278,807),(904,807)),
|
||||
((269,290),(644,290)),
|
||||
((630,268),(630,440)),
|
||||
((241,929),(882,288)),
|
||||
((864,907),(360,907)),
|
||||
((455,894),(455,265)),
|
||||
((257,43),(257,519)),
|
||||
((414,83),(360,83)),
|
||||
((237,64),(237,612)),
|
||||
((260,541),(260,927)),
|
||||
((323,909),(323,583)),
|
||||
((929,354),(929,695)),
|
||||
((912,914),(40,42)),
|
||||
((579,401),(392,401)),
|
||||
((389,222),(895,728)),
|
||||
((831,696),(831,707)),
|
||||
((871,304),(212,304)),
|
||||
((207,333),(621,333)),
|
||||
((225,897),(355,767)),
|
||||
((883,68),(84,867)),
|
||||
((115,397),(115,208)),
|
||||
((889,217),(985,217)),
|
||||
((793,402),(250,402)),
|
||||
((555,367),(61,861)),
|
||||
((732,954),(466,688)),
|
||||
((39,564),(39,481)),
|
||||
((283,816),(346,816)),
|
||||
((383,506),(276,506)),
|
||||
((394,661),(394,143)),
|
||||
((988,983),(66,61)),
|
||||
((652,638),(652,569)),
|
||||
((185,64),(487,64)),
|
||||
((354,935),(251,935)),
|
||||
((201,460),(201,552)),
|
||||
((836,285),(836,666)),
|
||||
((878,312),(359,831)),
|
||||
((443,684),(887,240)),
|
||||
((221,49),(948,776)),
|
||||
((243,959),(22,959)),
|
||||
((573,323),(834,323)),
|
||||
((745,734),(456,734)),
|
||||
((594,244),(908,244)),
|
||||
((583,360),(578,355)),
|
||||
((288,38),(288,364)),
|
||||
((565,339),(251,653)),
|
||||
((215,196),(215,476)),
|
||||
((270,705),(586,705)),
|
||||
((749,477),(749,658)),
|
||||
((917,838),(511,432)),
|
||||
((935,187),(935,381)),
|
||||
((181,190),(323,48)),
|
||||
((399,491),(399,779)),
|
||||
((861,798),(91,28)),
|
||||
((160,115),(58,115)),
|
||||
((940,68),(940,590)),
|
||||
((806,958),(35,187)),
|
||||
((184,538),(438,284)),
|
||||
((283,904),(283,114)),
|
||||
((344,935),(222,935)),
|
||||
((435,962),(367,962)),
|
||||
((837,768),(837,583)),
|
||||
((100,423),(826,423)),
|
||||
((299,172),(465,172)),
|
||||
((130,136),(181,187)),
|
||||
((969,759),(55,759)),
|
||||
((936,711),(521,711)),
|
||||
((268,619),(349,619)),
|
||||
((946,119),(108,957)),
|
||||
((940,25),(10,955)),
|
||||
((867,494),(652,279)),
|
||||
((535,202),(321,202)),
|
||||
((876,14),(24,866)),
|
||||
((887,208),(887,265)),
|
||||
((129,12),(42,12)),
|
||||
((514,800),(940,374)),
|
||||
((722,306),(722,418)),
|
||||
((24,928),(935,17)),
|
||||
((798,279),(798,293)),
|
||||
((384,701),(193,701)),
|
||||
((100,644),(593,644)),
|
||||
((818,48),(216,48)),
|
||||
((51,984),(949,86)),
|
||||
((843,494),(843,723)),
|
||||
((809,156),(129,836)),
|
||||
((500,38),(656,38)),
|
||||
((311,705),(311,101)),
|
||||
((21,850),(21,316)),
|
||||
((530,628),(511,628)),
|
||||
((106,366),(415,675)),
|
||||
((542,882),(325,665)),
|
||||
((987,937),(987,793)),
|
||||
((926,260),(264,922)),
|
||||
((768,149),(914,149)),
|
||||
((548,71),(548,812)),
|
||||
((51,946),(812,946)),
|
||||
((430,439),(954,963)),
|
||||
((529,301),(133,301)),
|
||||
((282,890),(720,890)),
|
||||
((876,231),(336,771)),
|
||||
((489,471),(934,471)),
|
||||
((585,174),(100,174)),
|
||||
((284,489),(163,489)),
|
||||
((989,983),(33,27)),
|
||||
((31,213),(662,213)),
|
||||
((133,832),(559,406)),
|
||||
((730,345),(730,194)),
|
||||
((860,288),(736,412)),
|
||||
((110,351),(581,351)),
|
||||
((417,151),(77,491)),
|
||||
((674,671),(674,711)),
|
||||
((514,867),(514,100)),
|
||||
((885,595),(885,680)),
|
||||
((44,31),(928,915)),
|
||||
((969,347),(69,347)),
|
||||
((597,227),(357,227)),
|
||||
((347,443),(347,216)),
|
||||
((781,736),(781,93)),
|
||||
((968,559),(968,81)),
|
||||
((35,93),(232,93)),
|
||||
((273,837),(97,837)),
|
||||
((949,833),(748,632)),
|
||||
((712,773),(221,773)),
|
||||
((194,884),(978,100)),
|
||||
((217,816),(217,861)),
|
||||
((651,122),(71,122)),
|
||||
((166,551),(166,892)),
|
||||
((285,193),(883,193)),
|
||||
((858,934),(125,201)),
|
||||
((180,190),(577,190)),
|
||||
((491,685),(690,486)),
|
||||
((666,598),(337,269)),
|
||||
((455,571),(753,571)),
|
||||
((11,769),(11,507)),
|
||||
((391,663),(323,595)),
|
||||
((70,740),(70,928)),
|
||||
((205,525),(534,854)),
|
||||
((890,851),(151,851)),
|
||||
((382,662),(849,195)),
|
||||
((201,870),(201,506)),
|
||||
((549,549),(549,528)),
|
||||
((343,172),(601,172)),
|
||||
((22,732),(750,732)),
|
||||
((221,689),(881,29)),
|
||||
((628,559),(747,559)),
|
||||
((668,879),(437,879)),
|
||||
((712,139),(38,139)),
|
||||
((547,322),(905,322)),
|
||||
((872,304),(719,304)),
|
||||
((469,604),(389,524)),
|
||||
((256,91),(746,91)),
|
||||
((881,548),(641,548)),
|
||||
((683,417),(683,800)),
|
||||
((811,917),(646,917)),
|
||||
((578,556),(207,185)),
|
||||
((732,343),(260,343)),
|
||||
((86,869),(882,73)),
|
||||
((370,587),(765,192)),
|
||||
((649,621),(649,165)),
|
||||
((298,339),(298,523)),
|
||||
((131,771),(803,99)),
|
||||
((934,791),(934,29)),
|
||||
((782,13),(782,741)),
|
||||
((852,808),(852,594)),
|
||||
((390,217),(153,217)),
|
||||
((858,980),(94,216)),
|
||||
((832,467),(783,418)),
|
||||
((188,49),(981,842)),
|
||||
((438,467),(76,829)),
|
||||
((47,911),(164,911)),
|
||||
((670,414),(533,414)),
|
||||
((58,61),(740,743)),
|
||||
((264,686),(264,799)),
|
||||
((506,300),(64,300)),
|
||||
((509,717),(509,952)),
|
||||
((81,819),(81,694)),
|
||||
((512,543),(427,543)),
|
||||
((235,78),(788,78)),
|
||||
((952,133),(644,133)),
|
||||
((188,302),(695,302)),
|
||||
((272,868),(845,295)),
|
||||
((288,413),(704,413)),
|
||||
((774,671),(774,24)),
|
||||
((296,932),(296,16)),
|
||||
((99,789),(300,789)),
|
||||
((630,560),(630,896)),
|
||||
((328,289),(280,289)),
|
||||
((786,772),(294,280)),
|
||||
((437,747),(437,110)),
|
||||
((537,709),(42,709)),
|
||||
((655,924),(655,117)),
|
||||
((185,65),(963,843)),
|
||||
((70,87),(274,87)),
|
||||
((516,727),(183,394)),
|
||||
((322,128),(781,587)),
|
||||
((147,278),(482,278)),
|
||||
((188,793),(761,793)),
|
||||
((702,441),(702,27)),
|
||||
((686,18),(686,275)),
|
||||
((510,254),(510,862)),
|
||||
((666,204),(12,204)),
|
||||
((677,63),(677,78)),
|
||||
((868,950),(868,110)),
|
||||
((42,845),(739,148)),
|
||||
((343,279),(758,279)),
|
||||
((182,792),(727,792)),
|
||||
((346,238),(493,238)),
|
||||
((467,493),(467,273)),
|
||||
((823,68),(823,886)),
|
||||
((686,302),(39,302)),
|
||||
((984,345),(984,936)),
|
||||
((11,480),(11,675)),
|
||||
((989,478),(695,772)),
|
||||
((568,235),(535,235)),
|
||||
((203,41),(93,41)),
|
||||
((463,569),(304,569)),
|
||||
((909,629),(207,629)),
|
||||
((792,678),(792,909)),
|
||||
((486,924),(486,948)),
|
||||
((611,79),(611,303)),
|
||||
((762,136),(139,759)),
|
||||
((808,872),(726,872)),
|
||||
((22,403),(22,401)),
|
||||
((774,134),(369,134)),
|
||||
((131,282),(131,849)),
|
||||
((912,245),(912,385)),
|
||||
((338,396),(768,396)),
|
||||
((944,978),(20,54)),
|
||||
((623,897),(623,10)),
|
||||
((103,402),(207,298)),
|
||||
((39,50),(971,50)),
|
||||
((770,423),(882,423)),
|
||||
((195,873),(195,40)),
|
||||
((119,659),(119,374)),
|
||||
((678,962),(698,962)),
|
||||
((946,64),(946,202)),
|
||||
((790,780),(790,66)),
|
||||
((565,21),(614,21)),
|
||||
((617,20),(640,20)),
|
||||
((697,773),(697,915)),
|
||||
((467,167),(208,167)),
|
||||
((567,713),(567,873)),
|
||||
((120,98),(557,98)),
|
||||
((103,395),(103,159)),
|
||||
((148,734),(723,159)),
|
||||
((730,949),(730,33)),
|
||||
((322,628),(322,272)),
|
||||
((649,57),(44,57)),
|
||||
((261,513),(624,513)),
|
||||
((550,414),(738,226)),
|
||||
((774,183),(471,486)),
|
||||
((146,659),(146,581)),
|
||||
((599,751),(599,320)),
|
||||
((936,225),(226,935)),
|
||||
((378,31),(222,187)),
|
||||
((871,691),(502,691)),
|
||||
((195,963),(335,963)),
|
||||
((513,465),(382,334)),
|
||||
((620,801),(673,801)),
|
||||
((187,428),(318,428)),
|
||||
((572,836),(441,836)),
|
||||
((305,398),(305,951)),
|
||||
((978,703),(927,703)),
|
||||
((99,219),(846,966)),
|
||||
((952,971),(26,45)),
|
||||
((859,775),(859,663)),
|
||||
((144,777),(144,390)),
|
||||
((792,859),(441,859)),
|
||||
((513,672),(982,203)),
|
||||
((613,342),(671,400)),
|
||||
((802,498),(811,498)),
|
||||
((197,240),(197,216)),
|
||||
((45,908),(881,72)),
|
||||
((860,573),(12,573)),
|
||||
((817,145),(755,83)),
|
||||
((565,562),(660,467)),
|
||||
((918,952),(918,111)),
|
||||
((936,174),(936,97)),
|
||||
((630,759),(630,89)),
|
||||
((329,762),(608,762)),
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
((0,9),(5,9)),
|
||||
((8,0),(0,8)),
|
||||
((9,4),(3,4)),
|
||||
((2,2),(2,1)),
|
||||
((7,0),(7,4)),
|
||||
((6,4),(2,0)),
|
||||
((0,9),(2,9)),
|
||||
((3,4),(1,4)),
|
||||
((0,0),(8,8)),
|
||||
((5,5),(8,2)),
|
||||
]
|
Loading…
Reference in New Issue