108612024-04-17 08:43:51AblablablaÉvzárócpp17Runtime error 33/100180ms131900 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

vector<bool> bejart;
vector<queue<pii>> csucsok;
vector<bool> ans;

void dfs(int akt, bool fiu){
    while(!csucsok[akt].empty()){
        pii kovi = csucsok[akt].front();
        csucsok[akt].pop();

        if(bejart[kovi.second]) continue;

        bejart[kovi.second] = 1;
        ans[kovi.second] = fiu;
        dfs(kovi.first, !fiu);
        return;
    }
}

int main(){
    int n;
    cin >> n;

    vector<pii> pontok(n);
    vector<int> pontX(n);
    vector<int> pontY(n);
    for(int i = 0; i < n; i++){
        cin >> pontok[i].first >> pontok[i].second;

        pontX[i] = pontok[i].first;
        pontY[i] = pontok[i].second;
    }

    sort(pontX.begin(), pontX.end());
    sort(pontY.begin(), pontY.end());

    pontX.erase(unique(pontX.begin(), pontX.end()), pontX.end());
    pontY.erase(unique(pontY.begin(), pontY.end()), pontY.end());

    csucsok.assign(2 * n, queue<pii>());
    for(int i = 0; i < n; i++){
        pontok[i].first = lower_bound(pontX.begin(), pontX.end(), pontok[i].first) - pontX.begin();
        pontok[i].second = lower_bound(pontY.begin(), pontY.end(), pontok[i].second) - pontY.begin();

        csucsok[pontok[i].first].push({pontok[i].second + n, i});
        csucsok[pontok[i].second + n].push({pontok[i].first, i});
    }

    bejart.assign(n, 0);
    ans.assign(n, 0);

    for(int i = 0; i < n; i++){
        bool fiu = 0;
        while(!csucsok[i].empty()){
            dfs(i, fiu);
            fiu = !fiu;
        }
    }

    for(bool x : ans){
        cout << (x ? "F" : "L");
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1884 KiB
2Runtime error165ms131900 KiB
subtask20/5
3Runtime error163ms131692 KiB
4Runtime error172ms131480 KiB
subtask30/7
5Runtime error163ms131692 KiB
6Runtime error172ms131480 KiB
7Runtime error159ms131460 KiB
8Runtime error165ms131260 KiB
9Runtime error178ms131020 KiB
10Runtime error179ms131012 KiB
subtask40/20
11Runtime error178ms130772 KiB
12Runtime error180ms130772 KiB
13Runtime error167ms130624 KiB
14Runtime error166ms130396 KiB
15Runtime error179ms130324 KiB
16Runtime error179ms130096 KiB
subtask513/13
17Accepted3ms4128 KiB
18Accepted3ms4376 KiB
19Accepted3ms4336 KiB
20Accepted3ms4440 KiB
21Accepted3ms4540 KiB
22Accepted3ms4508 KiB
23Accepted3ms4616 KiB
24Accepted3ms4516 KiB
25Accepted3ms4512 KiB
26Accepted3ms4508 KiB
27Accepted3ms4504 KiB
28Accepted3ms4500 KiB
29Accepted3ms4632 KiB
30Accepted3ms4780 KiB
31Accepted3ms4868 KiB
32Accepted3ms4852 KiB
33Accepted3ms4852 KiB
subtask620/20
34Accepted3ms4128 KiB
35Accepted3ms4376 KiB
36Accepted3ms4336 KiB
37Accepted3ms4440 KiB
38Accepted3ms4540 KiB
39Accepted3ms4508 KiB
40Accepted3ms4616 KiB
41Accepted3ms4516 KiB
42Accepted3ms4512 KiB
43Accepted3ms4508 KiB
44Accepted3ms4504 KiB
45Accepted3ms4500 KiB
46Accepted3ms4632 KiB
47Accepted3ms4780 KiB
48Accepted3ms4868 KiB
49Accepted3ms4852 KiB
50Accepted3ms4852 KiB
51Accepted4ms7416 KiB
52Accepted4ms7432 KiB
53Accepted4ms7456 KiB
54Accepted4ms7732 KiB
55Accepted4ms7720 KiB
56Accepted4ms7516 KiB
57Accepted4ms7400 KiB
58Accepted4ms7516 KiB
59Accepted4ms7444 KiB
60Accepted4ms7440 KiB
61Accepted4ms7444 KiB
62Accepted4ms7452 KiB
63Accepted4ms7712 KiB
64Accepted4ms7936 KiB
65Accepted4ms8048 KiB
subtask70/35
66Accepted3ms4128 KiB
67Runtime error173ms128696 KiB
68Runtime error163ms131692 KiB
69Runtime error172ms131480 KiB
70Runtime error159ms131460 KiB
71Runtime error165ms131260 KiB
72Runtime error178ms131020 KiB
73Runtime error179ms131012 KiB
74Runtime error178ms130772 KiB
75Runtime error180ms130772 KiB
76Runtime error167ms130624 KiB
77Runtime error166ms130396 KiB
78Runtime error179ms130324 KiB
79Runtime error179ms130096 KiB
80Accepted3ms4376 KiB
81Accepted3ms4336 KiB
82Accepted3ms4440 KiB
83Accepted3ms4540 KiB
84Accepted3ms4508 KiB
85Accepted3ms4616 KiB
86Accepted3ms4516 KiB
87Accepted3ms4512 KiB
88Accepted3ms4508 KiB
89Accepted3ms4504 KiB
90Accepted3ms4500 KiB
91Accepted3ms4632 KiB
92Accepted3ms4780 KiB
93Accepted3ms4868 KiB
94Accepted3ms4852 KiB
95Accepted3ms4852 KiB
96Accepted4ms7416 KiB
97Accepted4ms7432 KiB
98Accepted4ms7456 KiB
99Accepted4ms7732 KiB
100Accepted4ms7720 KiB
101Accepted4ms7516 KiB
102Accepted4ms7400 KiB
103Accepted4ms7516 KiB
104Accepted4ms7444 KiB
105Accepted4ms7440 KiB
106Accepted4ms7444 KiB
107Accepted4ms7452 KiB
108Accepted4ms7712 KiB
109Accepted4ms7936 KiB
110Accepted4ms8048 KiB
111Runtime error158ms128688 KiB
112Runtime error165ms128664 KiB
113Runtime error153ms128636 KiB
114Runtime error158ms128628 KiB
115Runtime error170ms128620 KiB
116Runtime error159ms128608 KiB
117Runtime error159ms128604 KiB
118Runtime error158ms128584 KiB
119Runtime error159ms128592 KiB
120Runtime error160ms128576 KiB
121Runtime error158ms128576 KiB