Submission #343950

#TimeUsernameProblemLanguageResultExecution timeMemory
343950kkkMarriage questions (IZhO14_marriage)C++14
36 / 100
1598 ms9324 KiB
#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)

marriage.cpp: In function 'long long int rec(long long int, long long int, long long int)':
marriage.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<v[pr].size();i++)
      |                 ~^~~~~~~~~~~~~
marriage.cpp: In function 'int main()':
marriage.cpp:35:25: warning: unused variable 'p' [-Wunused-variable]
   35 |     long long n,k,i,a,b,p,j,brr=0;
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...