sacgajcvs

Untitled

Sep 16th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define N 105
  4. int dp[N][N],v[N];
  5. bool vis[N];
  6.  
  7. void solve()
  8. {
  9. int n;
  10. cin>>n;
  11. for(int i=0;i<n;i++)
  12. {
  13. for(int j=0;j<n;j++)
  14. {
  15. cin>>dp[i][j];
  16. }
  17. }
  18. for(int j=0;j<n;j++)
  19. {
  20. for(int i=0;i<n;i++)
  21. {
  22. v[j]+=dp[i][j];
  23. }
  24. }
  25. vector<int> ans;
  26. for(int i=0;i<n;i++)
  27. {
  28. int mx=-1,ps=-1;
  29. for(int j=0;j<n;j++)
  30. {
  31. if(vis[j])
  32. continue;
  33. if(mx<v[j])
  34. {
  35. mx=v[j];
  36. ps=j;
  37. }
  38. }
  39. ans.push_back(ps);
  40. vis[ps]=1;
  41. for(int j=0;j<n;j++)
  42. {
  43. if(vis[j])
  44. continue;
  45. v[j]-=dp[ps][j];
  46. }
  47. }
  48. for(int i=0;i<n;i++)
  49. cout<<ans[n-1-i]+1<<" ";
  50. cout<<endl;
  51. return;
  52. }
  53. int main()
  54. {
  55. int TESTS=1;
  56. while(TESTS--)
  57. {
  58. solve();
  59. }
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment