152292025-02-17 11:39:11MrkzVirágos rét (50 pont)cpp17Time limit exceeded 15/50300ms1068 KiB
#include <iostream>
#include <fstream>
using namespace std;
int N,K,megoldas;
int Ret[100000],St[100000],vegpontok[100000],kezdopontok[100000],db;
void Mutat(){
    for(int i=1;i<=K;i++)
        cout<<St[i]<<" ";
    cout<<endl;
}
bool vanMegoldas(int szint){
    if(szint!=K)
        return false;
    for(int i=1;i<=db;i++){
        if(St[szint]==vegpontok[i] && St[1]==kezdopontok[i])
            return false;
    }
    return true;
}
bool Jo(int szint){
    for (int i=1;i<szint;i++)
        if(St[i]>=St[szint])
            return false;
    return (Ret[St[szint]]==1);
}
void Back(int szint){
    if(vanMegoldas(szint-1)){
        megoldas++;
        vegpontok[++db]=St[K];
        kezdopontok[db]=St[1];
    }
    else for(int i=1;i<=N;i++){
        St[szint]=i;
        if(Jo(szint)){
            Back(szint+1);
        }
    }
}
int main()
{
    cin>>N>>K;
    for(int i=1;i<=N;i++)
        cin>>Ret[i];
    Back(1);
    cout<<megoldas;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Time limit exceeded0/0287ms832 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted3/31ms316 KiB
8Accepted3/31ms316 KiB
9Accepted3/32ms316 KiB
10Time limit exceeded0/2300ms316 KiB
11Time limit exceeded0/3280ms316 KiB
12Time limit exceeded0/2280ms316 KiB
13Time limit exceeded0/3282ms316 KiB
14Time limit exceeded0/2282ms820 KiB
15Time limit exceeded0/2300ms820 KiB
16Time limit exceeded0/3300ms748 KiB
17Time limit exceeded0/3284ms820 KiB
18Time limit exceeded0/3282ms1068 KiB
19Time limit exceeded0/3300ms808 KiB
20Time limit exceeded0/3300ms864 KiB
21Time limit exceeded0/3287ms820 KiB
22Time limit exceeded0/3286ms1004 KiB