Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set 6-prob 1
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.in");
- ofstream g("date.out");
- bool mat[101][101];
- int c[101];
- int main()
- {
- int n, p; f>>n>>p;
- for (int i=1; i<=n; ++i)
- for (int j=1; j<=n; ++j)
- f>>mat[i][j];
- int s, cnt, cmax=-1;
- c[1]=1;
- for (int i=2; i<=n; ++i)
- {
- s=0, cnt=1;
- for (int j=1; j<=i; ++j)
- if (mat[i][j])
- ++cnt, s+=c[j];
- c[i]=cnt*(cnt+1)/2-s;
- if (c[i]>cmax)
- cmax=c[i];
- }
- if (p>cmax)
- {
- int x=p-cmax, t=cmax;
- for (int i=n-x+1; i<=n; ++i)
- c[i]=++t;
- }
- for (int i=1; i<=n; ++i)
- g<<c[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement