Submission #1092398

# Submission time Handle Problem Language Result Execution time Memory
1092398 2024-09-24T02:00:02 Z juicy Chessboard (IZhO18_chessboard) C++17
100 / 100
136 ms 4444 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  auto calc = [&](int i, int l) {
    return i / (2 * l) * l + min(l, i % (2 * l));
  };

  int n, k; cin >> n >> k;
  vector<array<int, 4>> rect(k);
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < 4; ++j) {
      cin >> rect[i][j];
    }
  }
  long long res = (long long) n * n;
  for (int l = 1; l < n; ++l) {
    if (n % l == 0) {
      long long x = 2LL * calc(n, l) * (n - calc(n, l));
      for (auto [r1, c1, r2, c2] : rect) {
        int r = calc(r2, l) - calc(r1 - 1, l), c = calc(c2, l) - calc(c1 - 1, l);
        int cr = r2 - r1 + 1, cc = c2 - c1 + 1;
        x += 2LL * r * c + 2LL * (cr - r) * (cc - c) - (long long) cr * cc;
      }
      res = min({res, x, (long long) n * n - x});
    }
  }
  cout << res;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 3160 KB Output is correct
2 Correct 4 ms 856 KB Output is correct
3 Correct 9 ms 1884 KB Output is correct
4 Correct 9 ms 1884 KB Output is correct
5 Correct 12 ms 2452 KB Output is correct
6 Correct 8 ms 1628 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 8 ms 1628 KB Output is correct
9 Correct 20 ms 3788 KB Output is correct
10 Correct 14 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 7 ms 1116 KB Output is correct
17 Correct 15 ms 3052 KB Output is correct
18 Correct 19 ms 3396 KB Output is correct
19 Correct 36 ms 3160 KB Output is correct
20 Correct 42 ms 3420 KB Output is correct
21 Correct 16 ms 2908 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 10 ms 1628 KB Output is correct
24 Correct 18 ms 3164 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 13 ms 2140 KB Output is correct
27 Correct 15 ms 2412 KB Output is correct
28 Correct 19 ms 3420 KB Output is correct
29 Correct 6 ms 1372 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 3160 KB Output is correct
2 Correct 4 ms 856 KB Output is correct
3 Correct 9 ms 1884 KB Output is correct
4 Correct 9 ms 1884 KB Output is correct
5 Correct 12 ms 2452 KB Output is correct
6 Correct 8 ms 1628 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 8 ms 1628 KB Output is correct
9 Correct 20 ms 3788 KB Output is correct
10 Correct 14 ms 2396 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 7 ms 1116 KB Output is correct
27 Correct 15 ms 3052 KB Output is correct
28 Correct 19 ms 3396 KB Output is correct
29 Correct 36 ms 3160 KB Output is correct
30 Correct 42 ms 3420 KB Output is correct
31 Correct 16 ms 2908 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 10 ms 1628 KB Output is correct
34 Correct 18 ms 3164 KB Output is correct
35 Correct 3 ms 600 KB Output is correct
36 Correct 13 ms 2140 KB Output is correct
37 Correct 15 ms 2412 KB Output is correct
38 Correct 19 ms 3420 KB Output is correct
39 Correct 6 ms 1372 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 35 ms 3668 KB Output is correct
42 Correct 23 ms 4176 KB Output is correct
43 Correct 27 ms 3680 KB Output is correct
44 Correct 23 ms 3928 KB Output is correct
45 Correct 22 ms 4184 KB Output is correct
46 Correct 39 ms 3928 KB Output is correct
47 Correct 20 ms 3664 KB Output is correct
48 Correct 26 ms 3736 KB Output is correct
49 Correct 21 ms 3672 KB Output is correct
50 Correct 114 ms 3932 KB Output is correct
51 Correct 121 ms 4268 KB Output is correct
52 Correct 113 ms 3932 KB Output is correct
53 Correct 121 ms 4240 KB Output is correct
54 Correct 117 ms 3932 KB Output is correct
55 Correct 136 ms 4180 KB Output is correct
56 Correct 107 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 14 ms 3160 KB Output is correct
10 Correct 4 ms 856 KB Output is correct
11 Correct 9 ms 1884 KB Output is correct
12 Correct 9 ms 1884 KB Output is correct
13 Correct 12 ms 2452 KB Output is correct
14 Correct 8 ms 1628 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 8 ms 1628 KB Output is correct
17 Correct 20 ms 3788 KB Output is correct
18 Correct 14 ms 2396 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 7 ms 1116 KB Output is correct
35 Correct 15 ms 3052 KB Output is correct
36 Correct 19 ms 3396 KB Output is correct
37 Correct 36 ms 3160 KB Output is correct
38 Correct 42 ms 3420 KB Output is correct
39 Correct 16 ms 2908 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 10 ms 1628 KB Output is correct
42 Correct 18 ms 3164 KB Output is correct
43 Correct 3 ms 600 KB Output is correct
44 Correct 13 ms 2140 KB Output is correct
45 Correct 15 ms 2412 KB Output is correct
46 Correct 19 ms 3420 KB Output is correct
47 Correct 6 ms 1372 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 35 ms 3668 KB Output is correct
50 Correct 23 ms 4176 KB Output is correct
51 Correct 27 ms 3680 KB Output is correct
52 Correct 23 ms 3928 KB Output is correct
53 Correct 22 ms 4184 KB Output is correct
54 Correct 39 ms 3928 KB Output is correct
55 Correct 20 ms 3664 KB Output is correct
56 Correct 26 ms 3736 KB Output is correct
57 Correct 21 ms 3672 KB Output is correct
58 Correct 114 ms 3932 KB Output is correct
59 Correct 121 ms 4268 KB Output is correct
60 Correct 113 ms 3932 KB Output is correct
61 Correct 121 ms 4240 KB Output is correct
62 Correct 117 ms 3932 KB Output is correct
63 Correct 136 ms 4180 KB Output is correct
64 Correct 107 ms 3676 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 122 ms 4084 KB Output is correct
68 Correct 116 ms 3920 KB Output is correct
69 Correct 101 ms 3676 KB Output is correct
70 Correct 112 ms 3928 KB Output is correct
71 Correct 111 ms 3920 KB Output is correct
72 Correct 108 ms 3672 KB Output is correct
73 Correct 106 ms 3832 KB Output is correct
74 Correct 115 ms 3928 KB Output is correct
75 Correct 109 ms 3932 KB Output is correct
76 Correct 117 ms 3932 KB Output is correct
77 Correct 37 ms 4444 KB Output is correct
78 Correct 21 ms 3932 KB Output is correct
79 Correct 25 ms 3580 KB Output is correct
80 Correct 26 ms 3760 KB Output is correct
81 Correct 24 ms 3676 KB Output is correct
82 Correct 26 ms 4116 KB Output is correct
83 Correct 22 ms 3708 KB Output is correct
84 Correct 76 ms 4184 KB Output is correct
85 Correct 126 ms 4184 KB Output is correct
86 Correct 1 ms 344 KB Output is correct
87 Correct 1 ms 348 KB Output is correct
88 Correct 125 ms 4320 KB Output is correct
89 Correct 24 ms 1116 KB Output is correct
90 Correct 0 ms 348 KB Output is correct