171752025-05-28 11:20:03AblablablaVasútépítéscpp17Wrong answer 0/1001ms556 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

vector<vector<int>> csucsok, ans, egyutt, kor;
vector<bool> bejart;

int keres(int akt, int elozo){
    bejart[akt] = 1;
    egyutt.back().push_back(akt);
    int vissza = -1;

    for(int x : csucsok[akt]){
        if(x == elozo) continue;
        if(bejart[x]){
            vissza = x;
            continue;
        }

        int a = keres(x, akt);

        if(a != -1){
            vissza = a;
        }
    }

    if(vissza != -1){
        kor.back().push_back(akt);
    }

    if(vissza == akt){
        vissza = -1;
    }

    return vissza;
}

int lent = 0, fent = 1e9;

void berak(int i, int j){
    assert(ans[i][j] == -1 && ans[j][i] == -1);
    assert(i != j);

    ans[i][j] = lent;
    ans[j][i] = lent;
    lent++;
}

void megold(int akt){
    bejart[akt] = 1;

    for(int x : csucsok[akt]){
        if(bejart[x]) continue;

        berak(akt, x);
        megold(x);
    }
}

int main()
{

    cout << "-1\n";
    /*int n, m;
    cin >> n >> m;


    csucsok.assign(n, vector<int>());
    ans.assign(n, vector<int>(n, -1));

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;

        csucsok[a].push_back(b);
        csucsok[b].push_back(a);
    }

    if(n < m){
        cout << "-1\n";
        return 0;
    }
    for(auto x : csucsok){
        if(x.size() == 0){
            cout << "-1\n";
            return 0;
        }
    }

    bejart.assign(n, 0);

    for(int i = 0; i < n; i++){
        if(!bejart[i]){
            egyutt.push_back(vector<int>());
            kor.push_back(vector<int>());

            keres(i, -1);
        }
    }

    int k = egyutt.size();

    for(auto x : egyutt){
        int akt = 0;
        for(int y : x){
            akt += csucsok[y].size();
        }

        akt /= 2;

        if(akt != x.size() - 1 && akt != x.size()){
            cout << "-1\n";
            return 0;
        }
    }

    cout << "egyutt:\n";
    for(auto x : egyutt){
        for(int y : x){
            cout << y  << " ";
        }
        cout << "\n";
    }
    cout << "\n";

    bejart.assign(n, 0);

    for(int i = 0; i < k; i++){
        if(kor[i].size() == 0){
            // fa

            megold(egyutt[i][0]);
        } else{
            // fak vezetnek a korbe

            // korben eloszor

            for(int j = 0; j < kor[i].size(); j++){
                int elozo = (j - 1 + kor[i].size()) % kor[i].size();

                berak(kor[i][j], kor[i][elozo]);
                bejart[kor[i][j]] = 1;
            }

            // aztan fakban

            for(int x : kor[i]){
                megold(x);
            }
        }
    }

    /*for(int i = 0; i + 1 < n; i++){
        for(int j = i + 1; j < n; j++){
            if(ans[i][j] == -1){
                ans[i][j] = fent;
                fent--;
            }
        }
    }

    for(int i = 0; i + 1 < n; i++){
        for(int j = i + 1; j < n; j++){
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }*/

    /*for(auto x : ans){
        for(int y : x){
            cout << y << "\t";
        }

        cout << "\n";
    }*/
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer1ms316 KiB
2Accepted1ms508 KiB
3Wrong answer1ms316 KiB
subtask20/40
4Wrong answer1ms316 KiB
5Wrong answer1ms316 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms316 KiB
8Wrong answer1ms316 KiB
9Wrong answer1ms508 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
subtask30/60
12Wrong answer1ms316 KiB
13Wrong answer1ms316 KiB
14Wrong answer1ms316 KiB
15Wrong answer1ms316 KiB
16Wrong answer1ms316 KiB
17Wrong answer1ms508 KiB
18Wrong answer1ms316 KiB
19Wrong answer1ms316 KiB
20Wrong answer1ms512 KiB
21Wrong answer1ms512 KiB
22Wrong answer1ms316 KiB
23Wrong answer1ms512 KiB
24Wrong answer1ms316 KiB
25Wrong answer1ms316 KiB
26Wrong answer1ms556 KiB
27Wrong answer1ms500 KiB
28Accepted1ms316 KiB
29Accepted1ms316 KiB
30Accepted1ms316 KiB
31Accepted1ms316 KiB