154932025-02-20 07:28:13MrkzHálózati biztonság (50)cpp17Wrong answer 0/501ms544 KiB
#include <iostream>
#include <fstream>
using namespace std;
int N,M,K,u,v,db;
int kapcs[10000][10000],megoldas[10000][10000],St[10000],S[10000];
void beolvas(){
    ifstream f("halozat.be");
    f>>N>>M>>K;
    for(int i=1;i<=M;i++){
        f>>u>>v;
        kapcs[u][v]=1;
        kapcs[v][u]=1;
    }
    f.close();
}
void Mutat(int szint){
    /*db++;
    for(int i=1;i<=szint;i++)
        megoldas[db][i]=St[i];
    S[db]=szint;*/
    cout<<szint-1<<endl;
    for(int i=1;i<szint;i++)
        cout<<St[i]<<" ";
    cout<<endl;
}
bool vanMegoldas(int szint){
    if(szint<=1)
        return false;
    for(int i=1;i<=szint;i++){
        int k=0;
        for(int j=1;j<=szint;j++)
        if(kapcs[St[i]][St[j]]==1)
            k++;
        if(k<K)
            return false;
    }
    return true;
}
bool Jo(int szint){
    if(szint==1)
        return true;
    int k=0;
    for(int i=1;i<=N;i++){
        if(kapcs[szint][i]==1)
            k++;
    }
    if(k<K)
        return false;
    for(int i=1;i<szint;i++)
        if(St[i]>=St[szint])
            return false;
    return(kapcs[St[szint]][St[szint-1]]==1);
}
void Back(int szint){
    if(vanMegoldas(szint-1)){
        Mutat(szint);
    }
    for(int i=1;i<=N;i++){
        St[szint]=i;
        if(Jo(szint))
            Back(szint+1);
    }
}
int main()
{
    beolvas();
    Back(1);
    /*for(int i=1;i<=db;i++){
        for(int j=1;j<S[db];j++)
            cout<<megoldas[i][j]<<" ";
        cout<<endl;
    }*/
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/31ms316 KiB
14Wrong answer0/31ms316 KiB
15Wrong answer0/31ms316 KiB
16Wrong answer0/31ms316 KiB
17Wrong answer0/31ms316 KiB
18Wrong answer0/31ms316 KiB
19Wrong answer0/31ms316 KiB
20Wrong answer0/31ms316 KiB
21Wrong answer0/31ms544 KiB
22Wrong answer0/31ms316 KiB