#include <bits/stdc++.h>
using namespace std;
const int c=8e5+5;
vector<int> compx;
vector<int> compy;
int fx(int k){
return lower_bound(compx.begin(),compx.end(),k)-compx.begin() + 1;
}
int fy(int k){
return lower_bound(compy.begin(),compy.end(),k)-compy.begin() + 1 + compx.size();
}
int n,N;
vector<pair<int,int>> adj[c];
bool volt[c];
int idx[c];
bool ans[c], vis[c], deg[c];
vector<pair<int,int>> edg;
void dfs(int v){
vis[v]=1;
while(idx[v]<adj[v].size()){
int x=idx[v];
int id=adj[v][x].second;
if(volt[id]){
++idx[v];
continue;
}
volt[id]=1;
++idx[v];
if(v<=compx.size()) ans[id]=1;
else ans[id]=0;
dfs(adj[v][x].first);
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
int a,b; cin>>a>>b;
edg.push_back(make_pair(a,b));
compx.push_back(a);
compy.push_back(b);
}
sort(compx.begin(),compx.end());
compx.resize(unique(compx.begin(),compx.end())-compx.begin());
sort(compy.begin(),compy.end());
compy.resize(unique(compy.begin(),compy.end())-compy.begin());
N=compx.size()+compy.size();
for(int i=0;i<n;i++){
int a=fx(edg[i].first);
int b=fy(edg[i].second);
adj[a].push_back(make_pair(b,i));
adj[b].push_back(make_pair(a,i));
deg[a]^=1; deg[b]^=1;
}
int m=n;
int p=-1;
for(int i=1;i<=N;i++){
if(deg[i]){
if(p==-1) p=i;
else{
adj[i].push_back(make_pair(p,m));
adj[p].push_back(make_pair(i,m++));
p=-1;
}
}
}
for(int i=1;i<=N;i++){
if(!vis[i]) dfs(i);
}
for(int i=0;i<n;i++){
if(ans[i]) cout << "L";
else cout << "F";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 39480 KiB | ||||
2 | Accepted | 104ms | 61876 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 115ms | 71516 KiB | ||||
4 | Accepted | 130ms | 71760 KiB | ||||
subtask3 | 7/7 | ||||||
5 | Accepted | 115ms | 71516 KiB | ||||
6 | Accepted | 130ms | 71760 KiB | ||||
7 | Accepted | 127ms | 72288 KiB | ||||
8 | Accepted | 146ms | 72840 KiB | ||||
9 | Accepted | 158ms | 73600 KiB | ||||
10 | Accepted | 221ms | 84476 KiB | ||||
subtask4 | 20/20 | ||||||
11 | Accepted | 148ms | 60240 KiB | ||||
12 | Accepted | 145ms | 58372 KiB | ||||
13 | Accepted | 144ms | 58504 KiB | ||||
14 | Accepted | 143ms | 58860 KiB | ||||
15 | Accepted | 141ms | 58820 KiB | ||||
16 | Accepted | 186ms | 75904 KiB | ||||
subtask5 | 13/13 | ||||||
17 | Accepted | 19ms | 41676 KiB | ||||
18 | Accepted | 17ms | 41892 KiB | ||||
19 | Accepted | 19ms | 42104 KiB | ||||
20 | Accepted | 17ms | 42184 KiB | ||||
21 | Accepted | 16ms | 42188 KiB | ||||
22 | Accepted | 19ms | 42184 KiB | ||||
23 | Accepted | 17ms | 42412 KiB | ||||
24 | Accepted | 16ms | 42620 KiB | ||||
25 | Accepted | 16ms | 42612 KiB | ||||
26 | Accepted | 19ms | 42612 KiB | ||||
27 | Accepted | 19ms | 42396 KiB | ||||
28 | Accepted | 19ms | 42404 KiB | ||||
29 | Accepted | 17ms | 42396 KiB | ||||
30 | Accepted | 19ms | 42492 KiB | ||||
31 | Accepted | 19ms | 42496 KiB | ||||
32 | Accepted | 19ms | 42400 KiB | ||||
33 | Accepted | 19ms | 42408 KiB | ||||
subtask6 | 20/20 | ||||||
34 | Accepted | 19ms | 41676 KiB | ||||
35 | Accepted | 17ms | 41892 KiB | ||||
36 | Accepted | 19ms | 42104 KiB | ||||
37 | Accepted | 17ms | 42184 KiB | ||||
38 | Accepted | 16ms | 42188 KiB | ||||
39 | Accepted | 19ms | 42184 KiB | ||||
40 | Accepted | 17ms | 42412 KiB | ||||
41 | Accepted | 16ms | 42620 KiB | ||||
42 | Accepted | 16ms | 42612 KiB | ||||
43 | Accepted | 19ms | 42612 KiB | ||||
44 | Accepted | 19ms | 42396 KiB | ||||
45 | Accepted | 19ms | 42404 KiB | ||||
46 | Accepted | 17ms | 42396 KiB | ||||
47 | Accepted | 19ms | 42492 KiB | ||||
48 | Accepted | 19ms | 42496 KiB | ||||
49 | Accepted | 19ms | 42400 KiB | ||||
50 | Accepted | 19ms | 42408 KiB | ||||
51 | Accepted | 21ms | 42624 KiB | ||||
52 | Accepted | 18ms | 42616 KiB | ||||
53 | Accepted | 17ms | 42612 KiB | ||||
54 | Accepted | 20ms | 42504 KiB | ||||
55 | Accepted | 20ms | 42644 KiB | ||||
56 | Accepted | 20ms | 42740 KiB | ||||
57 | Accepted | 17ms | 42736 KiB | ||||
58 | Accepted | 17ms | 42740 KiB | ||||
59 | Accepted | 20ms | 42864 KiB | ||||
60 | Accepted | 20ms | 42860 KiB | ||||
61 | Accepted | 17ms | 42656 KiB | ||||
62 | Accepted | 20ms | 42752 KiB | ||||
63 | Accepted | 17ms | 42748 KiB | ||||
64 | Accepted | 17ms | 42656 KiB | ||||
65 | Accepted | 21ms | 42652 KiB | ||||
subtask7 | 35/35 | ||||||
66 | Accepted | 19ms | 41676 KiB | ||||
67 | Accepted | 104ms | 64620 KiB | ||||
68 | Accepted | 115ms | 71516 KiB | ||||
69 | Accepted | 130ms | 71760 KiB | ||||
70 | Accepted | 127ms | 72288 KiB | ||||
71 | Accepted | 146ms | 72840 KiB | ||||
72 | Accepted | 158ms | 73600 KiB | ||||
73 | Accepted | 221ms | 84476 KiB | ||||
74 | Accepted | 148ms | 60240 KiB | ||||
75 | Accepted | 145ms | 58372 KiB | ||||
76 | Accepted | 144ms | 58504 KiB | ||||
77 | Accepted | 143ms | 58860 KiB | ||||
78 | Accepted | 141ms | 58820 KiB | ||||
79 | Accepted | 186ms | 75904 KiB | ||||
80 | Accepted | 17ms | 41892 KiB | ||||
81 | Accepted | 19ms | 42104 KiB | ||||
82 | Accepted | 17ms | 42184 KiB | ||||
83 | Accepted | 16ms | 42188 KiB | ||||
84 | Accepted | 19ms | 42184 KiB | ||||
85 | Accepted | 17ms | 42412 KiB | ||||
86 | Accepted | 16ms | 42620 KiB | ||||
87 | Accepted | 16ms | 42612 KiB | ||||
88 | Accepted | 19ms | 42612 KiB | ||||
89 | Accepted | 19ms | 42396 KiB | ||||
90 | Accepted | 19ms | 42404 KiB | ||||
91 | Accepted | 17ms | 42396 KiB | ||||
92 | Accepted | 19ms | 42492 KiB | ||||
93 | Accepted | 19ms | 42496 KiB | ||||
94 | Accepted | 19ms | 42400 KiB | ||||
95 | Accepted | 19ms | 42408 KiB | ||||
96 | Accepted | 21ms | 42624 KiB | ||||
97 | Accepted | 18ms | 42616 KiB | ||||
98 | Accepted | 17ms | 42612 KiB | ||||
99 | Accepted | 20ms | 42504 KiB | ||||
100 | Accepted | 20ms | 42644 KiB | ||||
101 | Accepted | 20ms | 42740 KiB | ||||
102 | Accepted | 17ms | 42736 KiB | ||||
103 | Accepted | 17ms | 42740 KiB | ||||
104 | Accepted | 20ms | 42864 KiB | ||||
105 | Accepted | 20ms | 42860 KiB | ||||
106 | Accepted | 17ms | 42656 KiB | ||||
107 | Accepted | 20ms | 42752 KiB | ||||
108 | Accepted | 17ms | 42748 KiB | ||||
109 | Accepted | 17ms | 42656 KiB | ||||
110 | Accepted | 21ms | 42652 KiB | ||||
111 | Accepted | 97ms | 62604 KiB | ||||
112 | Accepted | 93ms | 63648 KiB | ||||
113 | Accepted | 93ms | 63608 KiB | ||||
114 | Accepted | 92ms | 64524 KiB | ||||
115 | Accepted | 97ms | 63936 KiB | ||||
116 | Accepted | 94ms | 64328 KiB | ||||
117 | Accepted | 97ms | 63184 KiB | ||||
118 | Accepted | 90ms | 63708 KiB | ||||
119 | Accepted | 96ms | 64264 KiB | ||||
120 | Accepted | 105ms | 63732 KiB | ||||
121 | Accepted | 93ms | 64340 KiB |