Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream in("colorfulconflict.in");
  4. ofstream out("colorfulconflict.out");
  5. vector <pair <int, int> > v[40005];
  6. int s[205][205];
  7. int c[205][205];
  8. int main()
  9. {
  10. int n;
  11. in >> n;
  12. if(n > 200)
  13. {
  14. out << "-1";
  15. return 0;
  16. }
  17. int mx = 0;
  18. for(int i = 1; i <= n; i ++)
  19. {
  20. for(int j = 1; j <= n; j ++)
  21. {
  22. int a;
  23. in >> a;
  24. mx = max(mx, a);
  25. v[a].push_back(make_pair(i, j));
  26. }
  27. }
  28. for(int x = 1; x <= mx; x ++)
  29. {
  30. int mn = (1 << 30);
  31. int pozx1 = 0, pozx2 = 0, pozy1 = 0, pozy2 = 0;
  32.  
  33. int mxx = 0, okj = 0, oki = 0;
  34. for(int i = 0; i < v[x].size(); i ++)
  35. {
  36. for(int j = i + 1; j < v[x].size(); j ++)
  37. {
  38. int a = max(v[x][j].second, v[x][i].second) - min(v[x][j].second, v[x][i].second) + 1;
  39. int b = max(v[x][j].first, v[x][i].first) - min(v[x][j].first, v[x][i].first) + 1;
  40. if(mxx < a * b)
  41. mxx = a * b, okj = j, oki = i;
  42. }
  43. }
  44. if(mn > mxx && mxx)
  45. {
  46. pozx1 = v[x][oki].first;
  47. pozy1 = v[x][oki].second;
  48. pozx2 = v[x][okj].first;
  49. pozy2 = v[x][okj].second;
  50. mn = min(mn, mxx);
  51. }
  52. cout << x << " " << pozx1 << " " << pozy1 << " " << pozx2 << " " << pozy2 << '\n';
  53. for(int i = min(pozx1, pozx2); i <= max(pozx1, pozx2); i ++)
  54. {
  55. for(int j = min(pozy1, pozy2); j <= max(pozy1, pozy2); j ++)
  56. s[i][j] ++;
  57. }
  58. ///s[pozx1][pozy1] ++;
  59. ///s[pozx1][pozy2 + 1] --;
  60. ///s[pozx2][pozy1 + 1] --;
  61. ///s[pozx2 + 1][pozy2 + 1] ++;
  62. }
  63. for(int i = 1; i <= n; i ++)
  64. {
  65. for(int j = 1; j <= n; j ++)
  66. {
  67. ///s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
  68. cout << s[i][j] << " ";
  69. }
  70. cout << '\n';
  71. }
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement