Advertisement
AlexAvram

Untitled

Nov 17th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. set 6-prob 1
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. ifstream f("date.in");
  6. ofstream g("date.out");
  7. bool mat[101][101];
  8. int c[101];
  9. int main()
  10. {
  11. int n, p; f>>n>>p;
  12. for (int i=1; i<=n; ++i)
  13. for (int j=1; j<=n; ++j)
  14. f>>mat[i][j];
  15.  
  16. int s, cnt, cmax=-1;
  17. c[1]=1;
  18. for (int i=2; i<=n; ++i)
  19. {
  20. s=0, cnt=1;
  21. for (int j=1; j<=i; ++j)
  22. if (mat[i][j])
  23. ++cnt, s+=c[j];
  24. c[i]=cnt*(cnt+1)/2-s;
  25. if (c[i]>cmax)
  26. cmax=c[i];
  27. }
  28.  
  29. if (p>cmax)
  30. {
  31. int x=p-cmax, t=cmax;
  32. for (int i=n-x+1; i<=n; ++i)
  33. c[i]=++t;
  34. }
  35. for (int i=1; i<=n; ++i)
  36. g<<c[i]<<" ";
  37. return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement