108662024-04-17 08:55:5342Évzárópypy3Runtime error 33/100263ms171616 KiB
# discrepancy, balanced 2-coloring, IMO6 1986

from sys import stdin, stdout
input=stdin.readline

def f(x,y):
    return 10**9*x+y

#def g(c):
#    return c//10**9,c%10**9

def main():
    N = int(input())
    d={}
    hor={}
    ver={}
    for i in range(N):
        x,y = list(map(int, input().split()))
        d[f(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[f(hor[y][2*i],y)].append(f(hor[y][2*i+1],y))
            except: graph[f(hor[y][2*i],y)] = [f(hor[y][2*i+1],y)]
            try: graph[f(hor[y][2*i+1],y)].append(f(hor[y][2*i],y))
            except: graph[f(hor[y][2*i+1],y)] = [f(hor[y][2*i],y)]
    for x in ver:
        for i in range(len(ver[x])//2):
            try: graph[f(x,ver[x][2*i])].append(f(x,ver[x][2*i+1]))
            except: graph[f(x,ver[x][2*i])] = [f(x,ver[x][2*i+1])]
            try: graph[f(x,ver[x][2*i+1])].append(f(x,ver[x][2*i]))
            except: graph[f(x,ver[x][2*i+1])] = [f(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
1Accepted48ms77304 KiB
2Runtime error230ms171616 KiB
subtask20/5
3Runtime error192ms171336 KiB
4Runtime error187ms170696 KiB
subtask30/7
5Runtime error192ms171336 KiB
6Runtime error187ms170696 KiB
7Runtime error194ms170548 KiB
8Runtime error238ms170296 KiB
9Runtime error224ms169996 KiB
10Runtime error174ms169672 KiB
subtask40/20
11Runtime error261ms169724 KiB
12Runtime error225ms169680 KiB
13Runtime error263ms169444 KiB
14Runtime error261ms169428 KiB
15Runtime error252ms169188 KiB
16Runtime error178ms169272 KiB
subtask513/13
17Accepted41ms79804 KiB
18Accepted46ms79436 KiB
19Accepted43ms80408 KiB
20Accepted39ms80120 KiB
21Accepted48ms80196 KiB
22Accepted48ms80764 KiB
23Accepted48ms80876 KiB
24Accepted46ms80624 KiB
25Accepted43ms80960 KiB
26Accepted46ms80320 KiB
27Accepted46ms80764 KiB
28Accepted43ms81044 KiB
29Accepted41ms81012 KiB
30Accepted46ms80944 KiB
31Accepted43ms81632 KiB
32Accepted46ms81268 KiB
33Accepted46ms81208 KiB
subtask620/20
34Accepted41ms79804 KiB
35Accepted46ms79436 KiB
36Accepted43ms80408 KiB
37Accepted39ms80120 KiB
38Accepted48ms80196 KiB
39Accepted48ms80764 KiB
40Accepted48ms80876 KiB
41Accepted46ms80624 KiB
42Accepted43ms80960 KiB
43Accepted46ms80320 KiB
44Accepted46ms80764 KiB
45Accepted43ms81044 KiB
46Accepted41ms81012 KiB
47Accepted46ms80944 KiB
48Accepted43ms81632 KiB
49Accepted46ms81268 KiB
50Accepted46ms81208 KiB
51Accepted71ms91956 KiB
52Accepted86ms92312 KiB
53Accepted75ms92420 KiB
54Accepted71ms92160 KiB
55Accepted64ms91772 KiB
56Accepted72ms91740 KiB
57Accepted72ms91924 KiB
58Accepted72ms92020 KiB
59Accepted74ms91632 KiB
60Accepted70ms91928 KiB
61Accepted67ms92076 KiB
62Accepted68ms92456 KiB
63Accepted68ms93040 KiB
64Accepted65ms91624 KiB
65Accepted76ms92676 KiB
subtask70/35
66Accepted41ms79804 KiB
67Runtime error217ms167400 KiB
68Runtime error192ms171336 KiB
69Runtime error187ms170696 KiB
70Runtime error194ms170548 KiB
71Runtime error238ms170296 KiB
72Runtime error224ms169996 KiB
73Runtime error174ms169672 KiB
74Runtime error261ms169724 KiB
75Runtime error225ms169680 KiB
76Runtime error263ms169444 KiB
77Runtime error261ms169428 KiB
78Runtime error252ms169188 KiB
79Runtime error178ms169272 KiB
80Accepted46ms79436 KiB
81Accepted43ms80408 KiB
82Accepted39ms80120 KiB
83Accepted48ms80196 KiB
84Accepted48ms80764 KiB
85Accepted48ms80876 KiB
86Accepted46ms80624 KiB
87Accepted43ms80960 KiB
88Accepted46ms80320 KiB
89Accepted46ms80764 KiB
90Accepted43ms81044 KiB
91Accepted41ms81012 KiB
92Accepted46ms80944 KiB
93Accepted43ms81632 KiB
94Accepted46ms81268 KiB
95Accepted46ms81208 KiB
96Accepted71ms91956 KiB
97Accepted86ms92312 KiB
98Accepted75ms92420 KiB
99Accepted71ms92160 KiB
100Accepted64ms91772 KiB
101Accepted72ms91740 KiB
102Accepted72ms91924 KiB
103Accepted72ms92020 KiB
104Accepted74ms91632 KiB
105Accepted70ms91928 KiB
106Accepted67ms92076 KiB
107Accepted68ms92456 KiB
108Accepted68ms93040 KiB
109Accepted65ms91624 KiB
110Accepted76ms92676 KiB
111Runtime error201ms167256 KiB
112Runtime error225ms167348 KiB
113Runtime error216ms167364 KiB
114Runtime error203ms167164 KiB
115Runtime error214ms167260 KiB
116Runtime error211ms167280 KiB
117Runtime error238ms167348 KiB
118Runtime error224ms167252 KiB
119Runtime error233ms167268 KiB
120Runtime error215ms167432 KiB
121Runtime error224ms167324 KiB