108652024-04-17 08:54:17AblablablaÉvzárócpp17Runtime error 33/100178ms131908 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(3 * 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});
    }

    /*for(int i = 0; i < n; i++){
        cout << pontok[i].first << " " << pontok[i].second << "\n";
    }*/

    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
1Accepted3ms1888 KiB
2Runtime error165ms131908 KiB
subtask20/5
3Runtime error168ms131664 KiB
4Runtime error172ms131428 KiB
subtask30/7
5Runtime error168ms131664 KiB
6Runtime error172ms131428 KiB
7Runtime error174ms131148 KiB
8Runtime error177ms131108 KiB
9Runtime error178ms130868 KiB
10Runtime error166ms130624 KiB
subtask40/20
11Runtime error178ms130480 KiB
12Runtime error178ms130248 KiB
13Runtime error165ms130024 KiB
14Runtime error165ms129796 KiB
15Runtime error178ms129792 KiB
16Runtime error178ms129792 KiB
subtask513/13
17Accepted3ms4292 KiB
18Accepted3ms4300 KiB
19Accepted3ms4512 KiB
20Accepted3ms4520 KiB
21Accepted3ms4600 KiB
22Accepted3ms4688 KiB
23Accepted3ms4760 KiB
24Accepted3ms4684 KiB
25Accepted3ms4732 KiB
26Accepted3ms4588 KiB
27Accepted3ms4668 KiB
28Accepted3ms4800 KiB
29Accepted3ms4928 KiB
30Accepted3ms5016 KiB
31Accepted3ms5000 KiB
32Accepted3ms5008 KiB
33Accepted3ms5140 KiB
subtask620/20
34Accepted3ms4292 KiB
35Accepted3ms4300 KiB
36Accepted3ms4512 KiB
37Accepted3ms4520 KiB
38Accepted3ms4600 KiB
39Accepted3ms4688 KiB
40Accepted3ms4760 KiB
41Accepted3ms4684 KiB
42Accepted3ms4732 KiB
43Accepted3ms4588 KiB
44Accepted3ms4668 KiB
45Accepted3ms4800 KiB
46Accepted3ms4928 KiB
47Accepted3ms5016 KiB
48Accepted3ms5000 KiB
49Accepted3ms5008 KiB
50Accepted3ms5140 KiB
51Accepted6ms8904 KiB
52Accepted6ms8900 KiB
53Accepted6ms9016 KiB
54Accepted6ms8892 KiB
55Accepted6ms8896 KiB
56Accepted6ms9004 KiB
57Accepted6ms8904 KiB
58Accepted6ms8976 KiB
59Accepted6ms8996 KiB
60Accepted4ms9116 KiB
61Accepted4ms9200 KiB
62Accepted4ms9072 KiB
63Accepted6ms9196 KiB
64Accepted4ms9192 KiB
65Accepted4ms9324 KiB
subtask70/35
66Accepted3ms4292 KiB
67Runtime error162ms128700 KiB
68Runtime error168ms131664 KiB
69Runtime error172ms131428 KiB
70Runtime error174ms131148 KiB
71Runtime error177ms131108 KiB
72Runtime error178ms130868 KiB
73Runtime error166ms130624 KiB
74Runtime error178ms130480 KiB
75Runtime error178ms130248 KiB
76Runtime error165ms130024 KiB
77Runtime error165ms129796 KiB
78Runtime error178ms129792 KiB
79Runtime error178ms129792 KiB
80Accepted3ms4300 KiB
81Accepted3ms4512 KiB
82Accepted3ms4520 KiB
83Accepted3ms4600 KiB
84Accepted3ms4688 KiB
85Accepted3ms4760 KiB
86Accepted3ms4684 KiB
87Accepted3ms4732 KiB
88Accepted3ms4588 KiB
89Accepted3ms4668 KiB
90Accepted3ms4800 KiB
91Accepted3ms4928 KiB
92Accepted3ms5016 KiB
93Accepted3ms5000 KiB
94Accepted3ms5008 KiB
95Accepted3ms5140 KiB
96Accepted6ms8904 KiB
97Accepted6ms8900 KiB
98Accepted6ms9016 KiB
99Accepted6ms8892 KiB
100Accepted6ms8896 KiB
101Accepted6ms9004 KiB
102Accepted6ms8904 KiB
103Accepted6ms8976 KiB
104Accepted6ms8996 KiB
105Accepted4ms9116 KiB
106Accepted4ms9200 KiB
107Accepted4ms9072 KiB
108Accepted6ms9196 KiB
109Accepted4ms9192 KiB
110Accepted4ms9324 KiB
111Runtime error158ms128672 KiB
112Runtime error153ms128644 KiB
113Runtime error156ms128596 KiB
114Runtime error162ms128612 KiB
115Runtime error170ms128604 KiB
116Runtime error159ms128596 KiB
117Runtime error159ms128596 KiB
118Runtime error171ms128592 KiB
119Runtime error172ms128572 KiB
120Runtime error172ms128588 KiB
121Runtime error156ms128588 KiB