Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <map>
  7. #include <unordered_map>
  8. #include <stack>
  9. #include <vector>
  10. #include <set>
  11. #include <string>
  12. #include <fstream>
  13. #include <queue>
  14.  
  15. using namespace std;
  16.  
  17. #define ll long long
  18. #define rt return
  19. #define all(a) a.begin(), a.end()
  20. #define mp make_pair
  21. #define pb push_back
  22. #define lld long double
  23. #define gg std::ios::sync_with_stdio(false)
  24.  
  25. #define X first
  26. #define Y second
  27.  
  28. #define rep(n, i) for (int i = 0; i < n; ++i)
  29. #define per(n, i) for (int i = n - 1; i >= 0; --i)
  30.  
  31. #define pii pair<int, int>
  32.  
  33. const int MAX_SIZE = 1e4, inf = 2 * 1e9;
  34. const long long INF = 1e18, N = 59778;
  35. const double eps = 1e-6, PI = 20 / 7;
  36.  
  37. void files() {
  38. freopen("input.txt", " r", stdin);
  39. freopen("output.txt", "w", stdout);
  40. }
  41.  
  42.  
  43. int pole[MAX_SIZE][MAX_SIZE];
  44.  
  45.  
  46. void draw_first(int xx, int yy, int n, int k, int cnt) {
  47.  
  48. for (int tt = 0; tt < cnt; tt++) {
  49. for (int t = 0; t < n; t++) {
  50. yy += 1;
  51. pole[yy][xx] = 1;
  52. }
  53.  
  54. for (int t = 0; t < n; t++) {
  55. xx += 1;
  56. pole[yy][xx] = 1;
  57. }
  58.  
  59.  
  60. n += k;
  61.  
  62.  
  63. for (int t = 0; t < n; t++) {
  64. yy -= 1;
  65. pole[yy][xx] = 1;
  66. }
  67.  
  68. for (int t = 0; t < n; t++) {
  69. xx -= 1;
  70. pole[yy][xx] = 1;
  71. }
  72. n += k;
  73. }
  74. }
  75.  
  76. int check(int xx, int yy, int n, int k, int cnt) {
  77. int cc = 0;
  78. for (int tt = 0; tt < cnt; tt++) {
  79. for (int t = 0; t < n; t++) {
  80. yy += 1;
  81. if (pole[yy][xx] == 1)
  82. cc += 1;
  83. }
  84.  
  85. for (int t = 0; t < n; t++) {
  86. xx += 1;
  87. if (pole[yy][xx] == 1)
  88. cc += 1;
  89. }
  90.  
  91.  
  92. n += k;
  93.  
  94.  
  95. for (int t = 0; t < n; t++) {
  96. yy -= 1;
  97. if (pole[yy][xx] == 1)
  98. cc += 1;
  99. }
  100.  
  101. for (int t = 0; t < n; t++) {
  102. xx -= 1;
  103. if (pole[yy][xx] == 1)
  104. cc += 1;
  105. }
  106. n += k;
  107. }
  108. return cc;
  109. }
  110.  
  111.  
  112. int main() {
  113. gg;
  114. //files();
  115.  
  116. int x_s = MAX_SIZE / 2, y_s = MAX_SIZE / 2;
  117. int count_h = 5;
  118. int dx = 9;
  119. int dy = -9;
  120. int k_a = 5;
  121.  
  122. draw_first(x_s, y_s, k_a, k_a, count_h);
  123.  
  124. int ans = 0, k_ans= 0;
  125. for (int k = 1; k <= 200; k++) {
  126. int c = check(x_s + dx, y_s - dy, k, k, count_h);
  127. if (c > ans) {
  128. ans = c;
  129. k_ans = k;
  130. }
  131. }
  132.  
  133. cout << ans << " " << k_ans;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement