Submission #57817731


Source Code Expand

Copy
import sys
testing = len(sys.argv) == 4 and sys.argv[3] == "myTest"
interactive = False
if testing:
cmd = sys.stdout
from time import time
start_time = int(round(time() * 1000))
readAll = open(sys.argv[1], 'r').read
sys.stdout = open(sys.argv[2], 'w')
else:
readAll = sys.stdin.read
# ############ ---- I/O Functions ---- ############
class InputData:
def __init__(self):
self.lines = readAll().split('\n')
self.n = len(self.lines)
self.ii = -1
def input(self):
self.ii += 1
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import sys
testing = len(sys.argv) == 4 and sys.argv[3] == "myTest"
interactive = False
if testing:
    cmd = sys.stdout
    from time import time
    start_time = int(round(time() * 1000)) 
    readAll = open(sys.argv[1], 'r').read
    sys.stdout = open(sys.argv[2], 'w')
else:
    readAll = sys.stdin.read

# ############ ---- I/O Functions ---- ############

class InputData:
    def __init__(self):
        self.lines = readAll().split('\n')
        self.n = len(self.lines)
        self.ii = -1
    def input(self):
        self.ii += 1
        assert self.ii < self.n
        return self.lines[self.ii]

flush = sys.stdout.flush
if interactive and not testing:
    input = sys.stdin.readline
else:
    inputData = InputData()
    input = inputData.input

def intin():
    return(int(input()))
def intlin():
    return(list(map(int,input().split())))
def chrin():
    return(list(input()))
def strin():
    return input()
def lout(l, sep="\n", toStr=True):
    print(sep.join(map(str, l) if toStr else l))
def dout(*args, **kargs):
    if not testing: return
    if args: print(args[0] if len(args)==1 else args)
    if kargs: print([(k,v) for k,v in kargs.items()])
def ask(q):
    sys.stdout.write(str(q)+'\n')
    flush()
    return intin()
    
# ############ ---- I/O Functions ---- ############

# from math import ceil
# from collections import OrderedDict, defaultdict as ddict, Counter
# from heapq import *
# from Queue import Queue

# bf from small
def main():
    n = intin()
    ab = []
    d = []
    for _ in range(n):
        x,y = intlin()
        ab.append((x,y))
        dd = x+y
        d.append((x,y,dd))
    d.sort(key=lambda x:x[2])
    ans = []
    s = set()
    s.add((0,0))
    for xx,yy,dd in d:
        mini = 10e10
        x = -1
        y = -1
        for _x,_y in s:
            if xx < _x or yy < _y:
                continue
            if xx - _x + yy - _y < mini:
                x = _x
                y = _y
                mini = xx-x + yy-y
        s.add((xx,yy))
        if x != xx:
            s.add((x,yy))
            ans.append((x,y,x,yy))
            ans.append((x,yy,xx,yy))
        elif y != yy:
            s.add((xx,y))
            ans.append((x,y,xx,y))
            ans.append((xx,y,xx,yy))
        # else:
        #     assert False
        

    print(len(ans))
    for x in ans:
        lout(x,' ')


main()

if testing:
    sys.stdout = cmd
    print(int(round(time() * 1000))  - start_time)

Submission Info

Submission Time
Task A - Soda
User kagu
Language Python (PyPy 3.10-v7.3.12)
Score 3837012204
Code Size 2554 Byte
Status AC
Exec Time 92 ms
Memory 84256 KB

Judge Result

Set Name test_ALL
Score / Max Score 3837012204 / 150000000000
Status
AC × 150
Set Name Test Cases
test_ALL test_0000.txt, test_0001.txt, test_0002.txt, test_0003.txt, test_0004.txt, test_0005.txt, test_0006.txt, test_0007.txt, test_0008.txt, test_0009.txt, test_0010.txt, test_0011.txt, test_0012.txt, test_0013.txt, test_0014.txt, test_0015.txt, test_0016.txt, test_0017.txt, test_0018.txt, test_0019.txt, test_0020.txt, test_0021.txt, test_0022.txt, test_0023.txt, test_0024.txt, test_0025.txt, test_0026.txt, test_0027.txt, test_0028.txt, test_0029.txt, test_0030.txt, test_0031.txt, test_0032.txt, test_0033.txt, test_0034.txt, test_0035.txt, test_0036.txt, test_0037.txt, test_0038.txt, test_0039.txt, test_0040.txt, test_0041.txt, test_0042.txt, test_0043.txt, test_0044.txt, test_0045.txt, test_0046.txt, test_0047.txt, test_0048.txt, test_0049.txt, test_0050.txt, test_0051.txt, test_0052.txt, test_0053.txt, test_0054.txt, test_0055.txt, test_0056.txt, test_0057.txt, test_0058.txt, test_0059.txt, test_0060.txt, test_0061.txt, test_0062.txt, test_0063.txt, test_0064.txt, test_0065.txt, test_0066.txt, test_0067.txt, test_0068.txt, test_0069.txt, test_0070.txt, test_0071.txt, test_0072.txt, test_0073.txt, test_0074.txt, test_0075.txt, test_0076.txt, test_0077.txt, test_0078.txt, test_0079.txt, test_0080.txt, test_0081.txt, test_0082.txt, test_0083.txt, test_0084.txt, test_0085.txt, test_0086.txt, test_0087.txt, test_0088.txt, test_0089.txt, test_0090.txt, test_0091.txt, test_0092.txt, test_0093.txt, test_0094.txt, test_0095.txt, test_0096.txt, test_0097.txt, test_0098.txt, test_0099.txt, test_0100.txt, test_0101.txt, test_0102.txt, test_0103.txt, test_0104.txt, test_0105.txt, test_0106.txt, test_0107.txt, test_0108.txt, test_0109.txt, test_0110.txt, test_0111.txt, test_0112.txt, test_0113.txt, test_0114.txt, test_0115.txt, test_0116.txt, test_0117.txt, test_0118.txt, test_0119.txt, test_0120.txt, test_0121.txt, test_0122.txt, test_0123.txt, test_0124.txt, test_0125.txt, test_0126.txt, test_0127.txt, test_0128.txt, test_0129.txt, test_0130.txt, test_0131.txt, test_0132.txt, test_0133.txt, test_0134.txt, test_0135.txt, test_0136.txt, test_0137.txt, test_0138.txt, test_0139.txt, test_0140.txt, test_0141.txt, test_0142.txt, test_0143.txt, test_0144.txt, test_0145.txt, test_0146.txt, test_0147.txt, test_0148.txt, test_0149.txt
Case Name Status Exec Time Memory
test_0000.txt AC 91 ms 84092 KB
test_0001.txt AC 89 ms 84220 KB
test_0002.txt AC 91 ms 83684 KB
test_0003.txt AC 91 ms 83616 KB
test_0004.txt AC 90 ms 83836 KB
test_0005.txt AC 90 ms 83772 KB
test_0006.txt AC 89 ms 83868 KB
test_0007.txt AC 90 ms 83876 KB
test_0008.txt AC 90 ms 83864 KB
test_0009.txt AC 90 ms 83716 KB
test_0010.txt AC 91 ms 84036 KB
test_0011.txt AC 90 ms 83840 KB
test_0012.txt AC 91 ms 84076 KB
test_0013.txt AC 90 ms 83704 KB
test_0014.txt AC 91 ms 84016 KB
test_0015.txt AC 90 ms 83676 KB
test_0016.txt AC 89 ms 83680 KB
test_0017.txt AC 91 ms 84256 KB
test_0018.txt AC 90 ms 84252 KB
test_0019.txt AC 89 ms 83800 KB
test_0020.txt AC 91 ms 84084 KB
test_0021.txt AC 90 ms 84032 KB
test_0022.txt AC 91 ms 83808 KB
test_0023.txt AC 91 ms 83748 KB
test_0024.txt AC 90 ms 83572 KB
test_0025.txt AC 89 ms 84104 KB
test_0026.txt AC 90 ms 83680 KB
test_0027.txt AC 91 ms 83880 KB
test_0028.txt AC 90 ms 84196 KB
test_0029.txt AC 89 ms 83868 KB
test_0030.txt AC 90 ms 83636 KB
test_0031.txt AC 89 ms 83732 KB
test_0032.txt AC 92 ms 84104 KB
test_0033.txt AC 91 ms 83696 KB
test_0034.txt AC 91 ms 83832 KB
test_0035.txt AC 90 ms 83788 KB
test_0036.txt AC 90 ms 83984 KB
test_0037.txt AC 89 ms 84056 KB
test_0038.txt AC 91 ms 83788 KB
test_0039.txt AC 92 ms 84192 KB
test_0040.txt AC 90 ms 84072 KB
test_0041.txt AC 90 ms 83568 KB
test_0042.txt AC 91 ms 83652 KB
test_0043.txt AC 90 ms 84132 KB
test_0044.txt AC 92 ms 83800 KB
test_0045.txt AC 91 ms 83684 KB
test_0046.txt AC 92 ms 83832 KB
test_0047.txt AC 91 ms 84172 KB
test_0048.txt AC 91 ms 84028 KB
test_0049.txt AC 91 ms 83804 KB
test_0050.txt AC 91 ms 83536 KB
test_0051.txt AC 91 ms 83996 KB
test_0052.txt AC 91 ms 84004 KB
test_0053.txt AC 91 ms 83820 KB
test_0054.txt AC 90 ms 83884 KB
test_0055.txt AC 90 ms 83840 KB
test_0056.txt AC 91 ms 84200 KB
test_0057.txt AC 89 ms 83784 KB
test_0058.txt AC 91 ms 83840 KB
test_0059.txt AC 91 ms 84080 KB
test_0060.txt AC 90 ms 83880 KB
test_0061.txt AC 91 ms 83640 KB
test_0062.txt AC 91 ms 83784 KB
test_0063.txt AC 90 ms 84084 KB
test_0064.txt AC 90 ms 83860 KB
test_0065.txt AC 90 ms 83852 KB
test_0066.txt AC 92 ms 84144 KB
test_0067.txt AC 91 ms 83788 KB
test_0068.txt AC 90 ms 83796 KB
test_0069.txt AC 90 ms 83772 KB
test_0070.txt AC 90 ms 83864 KB
test_0071.txt AC 92 ms 83828 KB
test_0072.txt AC 90 ms 83856 KB
test_0073.txt AC 89 ms 83736 KB
test_0074.txt AC 91 ms 83676 KB
test_0075.txt AC 92 ms 84052 KB
test_0076.txt AC 90 ms 83944 KB
test_0077.txt AC 91 ms 84080 KB
test_0078.txt AC 89 ms 83652 KB
test_0079.txt AC 90 ms 83660 KB
test_0080.txt AC 91 ms 83796 KB
test_0081.txt AC 91 ms 83580 KB
test_0082.txt AC 90 ms 84060 KB
test_0083.txt AC 91 ms 84044 KB
test_0084.txt AC 90 ms 83856 KB
test_0085.txt AC 91 ms 83692 KB
test_0086.txt AC 91 ms 84176 KB
test_0087.txt AC 91 ms 83780 KB
test_0088.txt AC 89 ms 83692 KB
test_0089.txt AC 89 ms 83824 KB
test_0090.txt AC 90 ms 83668 KB
test_0091.txt AC 89 ms 83960 KB
test_0092.txt AC 89 ms 84096 KB
test_0093.txt AC 89 ms 83752 KB
test_0094.txt AC 90 ms 83876 KB
test_0095.txt AC 90 ms 83840 KB
test_0096.txt AC 90 ms 83744 KB
test_0097.txt AC 89 ms 83788 KB
test_0098.txt AC 90 ms 83764 KB
test_0099.txt AC 90 ms 83812 KB
test_0100.txt AC 90 ms 84120 KB
test_0101.txt AC 91 ms 83676 KB
test_0102.txt AC 90 ms 83952 KB
test_0103.txt AC 91 ms 83760 KB
test_0104.txt AC 90 ms 83800 KB
test_0105.txt AC 91 ms 83940 KB
test_0106.txt AC 90 ms 83612 KB
test_0107.txt AC 90 ms 83692 KB
test_0108.txt AC 91 ms 83892 KB
test_0109.txt AC 89 ms 83616 KB
test_0110.txt AC 90 ms 83948 KB
test_0111.txt AC 90 ms 84256 KB
test_0112.txt AC 91 ms 83692 KB
test_0113.txt AC 90 ms 84120 KB
test_0114.txt AC 91 ms 84080 KB
test_0115.txt AC 91 ms 84156 KB
test_0116.txt AC 91 ms 83660 KB
test_0117.txt AC 89 ms 84076 KB
test_0118.txt AC 89 ms 83840 KB
test_0119.txt AC 91 ms 84008 KB
test_0120.txt AC 89 ms 83804 KB
test_0121.txt AC 91 ms 84144 KB
test_0122.txt AC 91 ms 83800 KB
test_0123.txt AC 89 ms 83764 KB
test_0124.txt AC 89 ms 84052 KB
test_0125.txt AC 91 ms 84044 KB
test_0126.txt AC 91 ms 84052 KB
test_0127.txt AC 91 ms 83680 KB
test_0128.txt AC 90 ms 84104 KB
test_0129.txt AC 90 ms 84008 KB
test_0130.txt AC 90 ms 84136 KB
test_0131.txt AC 92 ms 84136 KB
test_0132.txt AC 91 ms 84104 KB
test_0133.txt AC 90 ms 83720 KB
test_0134.txt AC 90 ms 83888 KB
test_0135.txt AC 89 ms 83812 KB
test_0136.txt AC 91 ms 83800 KB
test_0137.txt AC 90 ms 83856 KB
test_0138.txt AC 91 ms 84088 KB
test_0139.txt AC 90 ms 84004 KB
test_0140.txt AC 91 ms 83828 KB
test_0141.txt AC 90 ms 83936 KB
test_0142.txt AC 91 ms 83696 KB
test_0143.txt AC 89 ms 83888 KB
test_0144.txt AC 90 ms 83976 KB
test_0145.txt AC 90 ms 83892 KB
test_0146.txt AC 91 ms 83692 KB
test_0147.txt AC 90 ms 83992 KB
test_0148.txt AC 89 ms 83692 KB
test_0149.txt AC 90 ms 83684 KB


2025-01-21 (Tue)
23:11:00 +00:00