# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
343950 | kkk | Marriage questions (IZhO14_marriage) | C++14 | 1598 ms | 9324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<cstring>
#include<vector>
#define endl '\n'
using namespace std;
vector <long long> v[300000];
bool used[3000];
long long br=0,le=0,m,bru=0;
long long rec(long long pr,long long fi,long long bru)
{
if(pr>fi)return 0;
long long rez=0;
for(int i=0;i<v[pr].size();i++)
{
if(!used[v[pr][i]])
{
if(pr==fi && bru==m-1)return 1;
used[v[pr][i]]=1;
rez+=rec(pr+1,fi,bru+1);
used[v[pr][i]]=0;
}
} rez+=rec(pr+1,fi,bru);
return rez;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,k,i,a,b,p,j,brr=0;
cin>>n>>m>>k;
for(i=0;i<k;i++)
{
cin>>a>>b;
v[a].push_back(b);
le=a;
}
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++){
//cout<<i<<" "<<j<<" "<<rec(i,j,0)<<endl;
if(rec(i,j,0)>0){brr+=n-j+1;break;}
memset(used,0,sizeof(used));
}
}
cout<<brr<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |