108582024-04-17 08:27:4242Évzárópython3Runtime error 33/100657ms135896 KiB
# discrepancy, balanced 2-coloring, IMO6 1986

from sys import stdin, stdout
input=stdin.readline

def main():
    N = int(input())
    points=[]
    d={}
    hor={}
    ver={}
    for i in range(N):
        x,y = list(map(int, input().split()))
        d[(x,y)] = len(points)
        points.append((x,y))
        try: hor[y].append(x)
        except: hor[y]=[x]
        try: ver[x].append(y)
        except: ver[x]=[y]
    res=['L']*len(points)
    graph={}
    for y in hor:
        for i in range(len(hor[y])//2):
            try: graph[(hor[y][2*i],y)].append((hor[y][2*i+1],y))
            except: graph[(hor[y][2*i],y)] = [(hor[y][2*i+1],y)]
            try: graph[(hor[y][2*i+1],y)].append((hor[y][2*i],y))
            except: graph[(hor[y][2*i+1],y)] = [(hor[y][2*i],y)]
    for x in ver:
        for i in range(len(ver[x])//2):
            try: graph[(x,ver[x][2*i])].append((x,ver[x][2*i+1]))
            except: graph[(x,ver[x][2*i])] = [(x,ver[x][2*i+1])]
            try: graph[(x,ver[x][2*i+1])].append((x,ver[x][2*i]))
            except: graph[(x,ver[x][2*i+1])] = [(x,ver[x][2*i])]
    while graph:
        v,cur=graph.popitem()
        l=1
        res[d[v]]='F'
        while cur:
            if l%2==0:
                for v in cur:
                    res[d[v]]='F'
            tmp=[]
            for v in cur:
                if v in graph:
                    sz=graph.pop(v)
                    for w in sz:
                        if w in graph:
                            tmp.append(w)
            cur=tmp
            l+=1
    print(''.join(res))
        
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted18ms11872 KiB
2Runtime error465ms135896 KiB
subtask20/5
3Runtime error509ms135884 KiB
4Runtime error597ms135728 KiB
subtask30/7
5Runtime error509ms135884 KiB
6Runtime error597ms135728 KiB
7Runtime error610ms135576 KiB
8Runtime error521ms135124 KiB
9Runtime error541ms135284 KiB
10Accepted646ms122740 KiB
subtask40/20
11Runtime error554ms135072 KiB
12Runtime error657ms134932 KiB
13Runtime error538ms134632 KiB
14Runtime error540ms134572 KiB
15Runtime error540ms134676 KiB
16Accepted546ms123416 KiB
subtask513/13
17Accepted17ms13784 KiB
18Accepted17ms14040 KiB
19Accepted17ms14192 KiB
20Accepted17ms14152 KiB
21Accepted17ms14332 KiB
22Accepted17ms14124 KiB
23Accepted17ms14404 KiB
24Accepted17ms14660 KiB
25Accepted17ms14368 KiB
26Accepted17ms14232 KiB
27Accepted17ms14520 KiB
28Accepted17ms14476 KiB
29Accepted17ms14312 KiB
30Accepted17ms14340 KiB
31Accepted17ms14356 KiB
32Accepted17ms14352 KiB
33Accepted17ms14644 KiB
subtask620/20
34Accepted17ms13784 KiB
35Accepted17ms14040 KiB
36Accepted17ms14192 KiB
37Accepted17ms14152 KiB
38Accepted17ms14332 KiB
39Accepted17ms14124 KiB
40Accepted17ms14404 KiB
41Accepted17ms14660 KiB
42Accepted17ms14368 KiB
43Accepted17ms14232 KiB
44Accepted17ms14520 KiB
45Accepted17ms14476 KiB
46Accepted17ms14312 KiB
47Accepted17ms14340 KiB
48Accepted17ms14356 KiB
49Accepted17ms14352 KiB
50Accepted17ms14644 KiB
51Accepted25ms16184 KiB
52Accepted24ms15964 KiB
53Accepted24ms15976 KiB
54Accepted24ms16084 KiB
55Accepted24ms15916 KiB
56Accepted25ms15688 KiB
57Accepted24ms15964 KiB
58Accepted24ms15892 KiB
59Accepted24ms15808 KiB
60Accepted23ms15692 KiB
61Accepted24ms15852 KiB
62Accepted24ms15912 KiB
63Accepted24ms15668 KiB
64Accepted24ms15904 KiB
65Accepted24ms15868 KiB
subtask70/35
66Accepted17ms13784 KiB
67Runtime error444ms133604 KiB
68Runtime error509ms135884 KiB
69Runtime error597ms135728 KiB
70Runtime error610ms135576 KiB
71Runtime error521ms135124 KiB
72Runtime error541ms135284 KiB
73Accepted646ms122740 KiB
74Runtime error554ms135072 KiB
75Runtime error657ms134932 KiB
76Runtime error538ms134632 KiB
77Runtime error540ms134572 KiB
78Runtime error540ms134676 KiB
79Accepted546ms123416 KiB
80Accepted17ms14040 KiB
81Accepted17ms14192 KiB
82Accepted17ms14152 KiB
83Accepted17ms14332 KiB
84Accepted17ms14124 KiB
85Accepted17ms14404 KiB
86Accepted17ms14660 KiB
87Accepted17ms14368 KiB
88Accepted17ms14232 KiB
89Accepted17ms14520 KiB
90Accepted17ms14476 KiB
91Accepted17ms14312 KiB
92Accepted17ms14340 KiB
93Accepted17ms14356 KiB
94Accepted17ms14352 KiB
95Accepted17ms14644 KiB
96Accepted25ms16184 KiB
97Accepted24ms15964 KiB
98Accepted24ms15976 KiB
99Accepted24ms16084 KiB
100Accepted24ms15916 KiB
101Accepted25ms15688 KiB
102Accepted24ms15964 KiB
103Accepted24ms15892 KiB
104Accepted24ms15808 KiB
105Accepted23ms15692 KiB
106Accepted24ms15852 KiB
107Accepted24ms15912 KiB
108Accepted24ms15668 KiB
109Accepted24ms15904 KiB
110Accepted24ms15868 KiB
111Runtime error412ms133736 KiB
112Runtime error407ms133496 KiB
113Runtime error409ms133636 KiB
114Runtime error412ms133700 KiB
115Runtime error409ms133352 KiB
116Runtime error416ms133660 KiB
117Runtime error421ms133740 KiB
118Runtime error412ms133644 KiB
119Runtime error418ms133616 KiB
120Runtime error481ms133492 KiB
121Runtime error412ms133600 KiB