Advertisement
a53

Stone

a53
Jan 5th, 2020
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int n,m,q,k,x,y,fx[6],fy[6];
  6.  
  7. int main()
  8. {
  9. cin>>n>>m>>k>>q;
  10. while(k--){
  11. cin>>x>>y;
  12. if(fx[x]!=1){fx[0]++;}
  13. fx[x]=1;
  14. if(fy[y]!=1){fy[0]++;}
  15. fy[y]=1;
  16. }
  17. ///Numarul de casute neatacate
  18. int s=n*m-m*fx[0]-n*fy[0]+fx[0]*fy[0];
  19. ///Imposibil
  20. if(s<q){
  21. cout<<"0";
  22. }
  23. else {
  24. ///Aranjamente fara repetitie de s luate cate q
  25. int p=1;
  26. for(int i=s-q+1;i<=s;i++){p*=i;}
  27. cout<<p;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement