Advertisement
denis_andrei10

Diana

Feb 27th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("elicop.in");
  5. ofstream fout("elicop.out");
  6. int a[105][105];
  7. int v[45];
  8. int main()
  9. {
  10. int i, j, m, n, k, l, l1, l2, c1, c2, p, nr0, nr1, x=0, raz, aux, perfecte=0, gresite=0;
  11. fin>>n>>m;
  12. for(i=1; i<=n; i++)
  13. {
  14. for(j=1; j<=m; j++)
  15. {
  16. fin>>a[i][j];
  17. }
  18. }
  19. fin>>k;
  20. for(l=1; l<=k; l++)
  21. {
  22. nr0=0;
  23. nr1=0;
  24. x=0;
  25. fin>>l1>>c1>>l2>>c2>>p;
  26. if(l1>l2)
  27. {
  28. aux=l1;
  29. l1=l2;
  30. l2=aux;
  31. aux=c1;
  32. c1=c2;
  33. c2=aux;
  34. }
  35. if(p!=1)
  36. {
  37. if(c1<c2)
  38. {
  39. for(i=l1; i<=l2; i++)
  40. {
  41. for(j=c1; j<=x+c1; j++)
  42. {
  43. if(a[i][j]==0)
  44. {
  45. nr0++;
  46. }
  47. else
  48. {
  49. nr1++;
  50. }
  51. }
  52. x++;
  53. }
  54. }
  55. else
  56. {
  57. for(i=l1; i<=l2; i++)
  58. {
  59. for(j=c1; j>=c1-x; j--)
  60. {
  61. if(a[i][j]==0)
  62. {
  63. nr0++;
  64. }
  65. else
  66. {
  67. nr1++;
  68. }
  69. }
  70. x++;
  71. }
  72. }
  73.  
  74. }
  75. else
  76. {
  77. if(c1>c2)
  78. {
  79. for(i=l1; i<=l2; i++)
  80. {
  81. for(j=c1-x; j>=c2; j--)
  82. {
  83. if(a[i][j]==0)
  84. {
  85. nr0++;
  86. }
  87. else
  88. {
  89. nr1++;
  90. }
  91. }
  92. x++;
  93. }
  94. }
  95. else
  96. {
  97. for(i=l1; i<=l2; i++)
  98. {
  99. for(j=c2; j>=c1+x; j--)
  100. {
  101. if(a[i][j]==0)
  102. {
  103. nr0++;
  104. }
  105. else
  106. {
  107. nr1++;
  108. }
  109. }
  110. x++;
  111. }
  112. }
  113. }
  114. if(nr0==0)
  115. {
  116. perfecte++;
  117. }
  118. if(nr0>nr1)
  119. {
  120. gresite++;
  121. v[gresite]=l;
  122. }
  123. }
  124. fout<<perfecte<<endl<<gresite<<' ';
  125. for(i=1; i<=gresite; i++)
  126. {
  127. fout<<v[i]<<' ';
  128. }
  129. return 0;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement