108592024-04-17 08:32:0442Évzárópypy3Runtime error 33/100264ms171692 KiB
# discrepancy, balanced 2-coloring, IMO6 1986

from sys import stdin, stdout
input=stdin.readline

def main():
    N = int(input())
    d={}
    hor={}
    ver={}
    for i in range(N):
        x,y = list(map(int, input().split()))
        d[(x,y)] = i
        try: hor[y].append(x)
        except: hor[y]=[x]
        try: ver[x].append(y)
        except: ver[x]=[y]
    res=['L']*N
    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
1Accepted41ms77268 KiB
2Runtime error264ms171692 KiB
subtask20/5
3Runtime error202ms171528 KiB
4Runtime error195ms171144 KiB
subtask30/7
5Runtime error202ms171528 KiB
6Runtime error195ms171144 KiB
7Runtime error200ms170988 KiB
8Runtime error195ms170660 KiB
9Runtime error254ms170248 KiB
10Runtime error173ms170084 KiB
subtask40/20
11Runtime error229ms169868 KiB
12Runtime error228ms169628 KiB
13Runtime error226ms169208 KiB
14Runtime error201ms168916 KiB
15Runtime error195ms169128 KiB
16Runtime error166ms169096 KiB
subtask513/13
17Accepted48ms80028 KiB
18Accepted46ms79744 KiB
19Accepted46ms80256 KiB
20Accepted48ms80384 KiB
21Accepted43ms80528 KiB
22Accepted46ms80732 KiB
23Accepted43ms80764 KiB
24Accepted50ms80632 KiB
25Accepted46ms81188 KiB
26Accepted46ms80824 KiB
27Accepted48ms81012 KiB
28Accepted43ms81112 KiB
29Accepted39ms81152 KiB
30Accepted41ms81648 KiB
31Accepted39ms81160 KiB
32Accepted41ms81420 KiB
33Accepted39ms81396 KiB
subtask620/20
34Accepted48ms80028 KiB
35Accepted46ms79744 KiB
36Accepted46ms80256 KiB
37Accepted48ms80384 KiB
38Accepted43ms80528 KiB
39Accepted46ms80732 KiB
40Accepted43ms80764 KiB
41Accepted50ms80632 KiB
42Accepted46ms81188 KiB
43Accepted46ms80824 KiB
44Accepted48ms81012 KiB
45Accepted43ms81112 KiB
46Accepted39ms81152 KiB
47Accepted41ms81648 KiB
48Accepted39ms81160 KiB
49Accepted41ms81420 KiB
50Accepted39ms81396 KiB
51Accepted75ms91752 KiB
52Accepted71ms92392 KiB
53Accepted67ms91624 KiB
54Accepted82ms91436 KiB
55Accepted70ms92308 KiB
56Accepted64ms91740 KiB
57Accepted64ms92000 KiB
58Accepted67ms92140 KiB
59Accepted65ms92168 KiB
60Accepted67ms92232 KiB
61Accepted64ms91768 KiB
62Accepted67ms92436 KiB
63Accepted68ms92044 KiB
64Accepted64ms91872 KiB
65Accepted68ms92412 KiB
subtask70/35
66Accepted48ms80028 KiB
67Runtime error225ms168132 KiB
68Runtime error202ms171528 KiB
69Runtime error195ms171144 KiB
70Runtime error200ms170988 KiB
71Runtime error195ms170660 KiB
72Runtime error254ms170248 KiB
73Runtime error173ms170084 KiB
74Runtime error229ms169868 KiB
75Runtime error228ms169628 KiB
76Runtime error226ms169208 KiB
77Runtime error201ms168916 KiB
78Runtime error195ms169128 KiB
79Runtime error166ms169096 KiB
80Accepted46ms79744 KiB
81Accepted46ms80256 KiB
82Accepted48ms80384 KiB
83Accepted43ms80528 KiB
84Accepted46ms80732 KiB
85Accepted43ms80764 KiB
86Accepted50ms80632 KiB
87Accepted46ms81188 KiB
88Accepted46ms80824 KiB
89Accepted48ms81012 KiB
90Accepted43ms81112 KiB
91Accepted39ms81152 KiB
92Accepted41ms81648 KiB
93Accepted39ms81160 KiB
94Accepted41ms81420 KiB
95Accepted39ms81396 KiB
96Accepted75ms91752 KiB
97Accepted71ms92392 KiB
98Accepted67ms91624 KiB
99Accepted82ms91436 KiB
100Accepted70ms92308 KiB
101Accepted64ms91740 KiB
102Accepted64ms92000 KiB
103Accepted67ms92140 KiB
104Accepted65ms92168 KiB
105Accepted67ms92232 KiB
106Accepted64ms91768 KiB
107Accepted67ms92436 KiB
108Accepted68ms92044 KiB
109Accepted64ms91872 KiB
110Accepted68ms92412 KiB
111Runtime error216ms167800 KiB
112Runtime error188ms167696 KiB
113Runtime error218ms167672 KiB
114Runtime error204ms167704 KiB
115Runtime error192ms167756 KiB
116Runtime error238ms167976 KiB
117Runtime error210ms167980 KiB
118Runtime error215ms167480 KiB
119Runtime error204ms167580 KiB
120Runtime error246ms167712 KiB
121Runtime error203ms167784 KiB