42852023-03-22 09:32:39tamasmarkTestnevelés óracpp17Wrong answer 0/50209ms28140 KiB
// torne ora.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#define ll long long

using namespace std;

struct adat
{
    ll db,szam;
    vector<ll>sz;
};
ll n, k, i,a,b;
bool t,p;
int hasonlit(adat a, adat b)
{
    t = false;
    p = false;
    if (a.db > b.db) return 1;
    else if (a.db == b.db)
    {
        for (auto& e : a.sz)
            if (e == b.szam) t = true;
        for (auto& e : b.sz)
            if (e == a.szam) p = true;
        if (t) return 0;
        else if (p) return 1;
    }
    else return 0;
}
int main()
{
    cin >> n >> k;
    deque<adat>x(n + 1);
    for (i = 1; i <= k; ++i)
    {
        cin >> a >> b;
        x[b].sz.push_back(a);
        x[a].db++;
        x[a].szam = a;
        x[b].szam = b;
    }
    x.pop_front();
    sort(x.begin(), x.end(), hasonlit);
    for (auto& e : x) cout << e.szam << " ";
    return 0;
}
/*
5 9
3 1
3 5
3 4
4 2
3 2
1 4
1 2
1 5
5 4


*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1876 KiB
2Runtime error0/03ms2200 KiB
3Runtime error0/0162ms17256 KiB
4Wrong answer0/23ms2560 KiB
5Runtime error0/33ms2860 KiB
6Wrong answer0/32ms2920 KiB
7Runtime error0/33ms3124 KiB
8Wrong answer0/13ms3184 KiB
9Wrong answer0/33ms3340 KiB
10Runtime error0/34ms3584 KiB
11Runtime error0/34ms3664 KiB
12Runtime error0/14ms3600 KiB
13Runtime error0/24ms3600 KiB
14Runtime error0/33ms3848 KiB
15Runtime error0/1204ms14268 KiB
16Runtime error0/3104ms19440 KiB
17Runtime error0/58ms20344 KiB
18Runtime error0/1172ms28140 KiB
19Runtime error0/2209ms14916 KiB
20Runtime error0/3129ms25912 KiB
21Runtime error0/4128ms26168 KiB
22Runtime error0/4148ms26072 KiB