153312025-02-18 13:17:31MrkzKombináció (50)cpp17Time limit exceeded 9/50300ms508 KiB
#include <iostream>

using namespace std;
int N,M,megoldas[100],St[100],elozo[100];
bool vanMegoldas(int szint){
    return (szint==M);
}
bool megoldas1(int szint){
    for(int i=1;i<=M;i++)
        if(St[i]!=megoldas[i])
        return false;
    return true;
}
bool megoldas2(int szint){
    for(int i=1;i<=M;i++)
        if(megoldas[i]!=elozo[i])
            return false;
    return true;
}
bool Jo(int szint){

    for(int i=1;i<szint;i++){
        if(St[szint]<=St[i])
            return false;
    }
    return true;
}
void Mutat(){
    for(int i=1;i<=M;i++)
        cout<<St[i]<<" ";
    cout<<endl;
}
void Back(int szint){
    if(vanMegoldas(szint-1)){
        if(megoldas1(szint-1)){
            for(int i=1;i<=M;i++)
                cout<<elozo[i]<<" ";
            cout<<endl;
        }
        if(megoldas2(szint-1)){
            Mutat();
            cout<<endl;
        }
        for(int i=1;i<=M;i++)
            elozo[i]=St[i];
    }
    else for(int i=1;i<=N;i++){
        St[szint]=i;
        if(Jo(szint))
            Back(szint+1);
    }
}
int main()
{
    cin>>N>>M;
    for(int i=1;i<=M;i++)
        cin>>megoldas[i];
    Back(1);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base9/50
1Accepted0/01ms316 KiB
2Time limit exceeded0/0277ms316 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Partially correct1/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Accepted2/21ms316 KiB
8Time limit exceeded0/2300ms316 KiB
9Time limit exceeded0/2300ms316 KiB
10Time limit exceeded0/4300ms316 KiB
11Time limit exceeded0/4282ms316 KiB
12Time limit exceeded0/4286ms316 KiB
13Accepted4/41ms316 KiB
14Time limit exceeded0/4286ms508 KiB
15Time limit exceeded0/4300ms316 KiB
16Time limit exceeded0/6287ms500 KiB
17Time limit exceeded0/6277ms316 KiB