#include <bits/stdc++.h>
using namespace std;
struct Data
{
int x1, y1, x2, y2;
Data() = default;
Data(int _x1, int _y1, int _x2, int _y2) : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
};
const long long INF = 1e18;
int main()
{
cin.tie(0)->sync_with_stdio(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int M, n; cin >> M >> n;
vector<Data> a(n);
for (int i = 0; i < n; i++)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
x1--, y1--;
a[i] = Data(x1, y1, x2, y2);
}
auto solve = [&](int K) -> long long
{
long long ret1 = (1ll * (M / K) * (M / K) / 2 + M / K % 2) * K * K;
for (int i = 0; i < n; i++)
{
int xx = a[i].x1 / K, yy = a[i].y1 / K;
if ((xx + yy) % 2 == 0)
ret1--;
else
ret1++;
}
long long ret2 = (1ll * (M / K) * (M / K) / 2) * K * K;
for (int i = 0; i < n; i++)
{
int xx = a[i].x1 / K, yy = a[i].y1 / K;
if ((xx + yy) % 2 == 1)
ret2--;
else
ret2++;
}
return min(ret1, ret2);
};
long long ans = INF;
for (int t = 1; t < M; t++)
if (M % t == 0)
ans = min(ans, solve(t));
cout << ans << '\n';
return 0;
}
# |
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 |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1368 KB |
Output is correct |
2 |
Correct |
5 ms |
604 KB |
Output is correct |
3 |
Correct |
12 ms |
856 KB |
Output is correct |
4 |
Correct |
11 ms |
1112 KB |
Output is correct |
5 |
Correct |
15 ms |
1112 KB |
Output is correct |
6 |
Correct |
10 ms |
860 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
856 KB |
Output is correct |
9 |
Correct |
23 ms |
1624 KB |
Output is correct |
10 |
Correct |
13 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 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 |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
9 ms |
1112 KB |
Output is correct |
17 |
Correct |
18 ms |
1624 KB |
Output is correct |
18 |
Correct |
26 ms |
1884 KB |
Output is correct |
19 |
Correct |
63 ms |
1624 KB |
Output is correct |
20 |
Correct |
71 ms |
1880 KB |
Output is correct |
21 |
Correct |
17 ms |
1624 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
16 ms |
1112 KB |
Output is correct |
24 |
Correct |
22 ms |
1624 KB |
Output is correct |
25 |
Correct |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
14 ms |
1112 KB |
Output is correct |
27 |
Correct |
20 ms |
1368 KB |
Output is correct |
28 |
Correct |
24 ms |
1880 KB |
Output is correct |
29 |
Correct |
7 ms |
856 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1368 KB |
Output is correct |
2 |
Correct |
5 ms |
604 KB |
Output is correct |
3 |
Correct |
12 ms |
856 KB |
Output is correct |
4 |
Correct |
11 ms |
1112 KB |
Output is correct |
5 |
Correct |
15 ms |
1112 KB |
Output is correct |
6 |
Correct |
10 ms |
860 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
856 KB |
Output is correct |
9 |
Correct |
23 ms |
1624 KB |
Output is correct |
10 |
Correct |
13 ms |
1116 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
9 ms |
1112 KB |
Output is correct |
27 |
Correct |
18 ms |
1624 KB |
Output is correct |
28 |
Correct |
26 ms |
1884 KB |
Output is correct |
29 |
Correct |
63 ms |
1624 KB |
Output is correct |
30 |
Correct |
71 ms |
1880 KB |
Output is correct |
31 |
Correct |
17 ms |
1624 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
16 ms |
1112 KB |
Output is correct |
34 |
Correct |
22 ms |
1624 KB |
Output is correct |
35 |
Correct |
3 ms |
600 KB |
Output is correct |
36 |
Correct |
14 ms |
1112 KB |
Output is correct |
37 |
Correct |
20 ms |
1368 KB |
Output is correct |
38 |
Correct |
24 ms |
1880 KB |
Output is correct |
39 |
Correct |
7 ms |
856 KB |
Output is correct |
40 |
Correct |
1 ms |
344 KB |
Output is correct |
41 |
Correct |
60 ms |
1624 KB |
Output is correct |
42 |
Correct |
29 ms |
1880 KB |
Output is correct |
43 |
Correct |
39 ms |
1624 KB |
Output is correct |
44 |
Correct |
28 ms |
1880 KB |
Output is correct |
45 |
Correct |
25 ms |
1880 KB |
Output is correct |
46 |
Correct |
68 ms |
1880 KB |
Output is correct |
47 |
Correct |
23 ms |
1624 KB |
Output is correct |
48 |
Correct |
33 ms |
1624 KB |
Output is correct |
49 |
Correct |
25 ms |
1624 KB |
Output is correct |
50 |
Correct |
263 ms |
1880 KB |
Output is correct |
51 |
Correct |
282 ms |
1880 KB |
Output is correct |
52 |
Correct |
262 ms |
1628 KB |
Output is correct |
53 |
Correct |
285 ms |
1880 KB |
Output is correct |
54 |
Correct |
258 ms |
1624 KB |
Output is correct |
55 |
Correct |
291 ms |
1880 KB |
Output is correct |
56 |
Correct |
251 ms |
1628 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 |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
17 ms |
1368 KB |
Output is correct |
10 |
Correct |
5 ms |
604 KB |
Output is correct |
11 |
Correct |
12 ms |
856 KB |
Output is correct |
12 |
Correct |
11 ms |
1112 KB |
Output is correct |
13 |
Correct |
15 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
860 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
856 KB |
Output is correct |
17 |
Correct |
23 ms |
1624 KB |
Output is correct |
18 |
Correct |
13 ms |
1116 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
9 ms |
1112 KB |
Output is correct |
35 |
Correct |
18 ms |
1624 KB |
Output is correct |
36 |
Correct |
26 ms |
1884 KB |
Output is correct |
37 |
Correct |
63 ms |
1624 KB |
Output is correct |
38 |
Correct |
71 ms |
1880 KB |
Output is correct |
39 |
Correct |
17 ms |
1624 KB |
Output is correct |
40 |
Correct |
1 ms |
344 KB |
Output is correct |
41 |
Correct |
16 ms |
1112 KB |
Output is correct |
42 |
Correct |
22 ms |
1624 KB |
Output is correct |
43 |
Correct |
3 ms |
600 KB |
Output is correct |
44 |
Correct |
14 ms |
1112 KB |
Output is correct |
45 |
Correct |
20 ms |
1368 KB |
Output is correct |
46 |
Correct |
24 ms |
1880 KB |
Output is correct |
47 |
Correct |
7 ms |
856 KB |
Output is correct |
48 |
Correct |
1 ms |
344 KB |
Output is correct |
49 |
Correct |
60 ms |
1624 KB |
Output is correct |
50 |
Correct |
29 ms |
1880 KB |
Output is correct |
51 |
Correct |
39 ms |
1624 KB |
Output is correct |
52 |
Correct |
28 ms |
1880 KB |
Output is correct |
53 |
Correct |
25 ms |
1880 KB |
Output is correct |
54 |
Correct |
68 ms |
1880 KB |
Output is correct |
55 |
Correct |
23 ms |
1624 KB |
Output is correct |
56 |
Correct |
33 ms |
1624 KB |
Output is correct |
57 |
Correct |
25 ms |
1624 KB |
Output is correct |
58 |
Correct |
263 ms |
1880 KB |
Output is correct |
59 |
Correct |
282 ms |
1880 KB |
Output is correct |
60 |
Correct |
262 ms |
1628 KB |
Output is correct |
61 |
Correct |
285 ms |
1880 KB |
Output is correct |
62 |
Correct |
258 ms |
1624 KB |
Output is correct |
63 |
Correct |
291 ms |
1880 KB |
Output is correct |
64 |
Correct |
251 ms |
1628 KB |
Output is correct |
65 |
Correct |
1 ms |
344 KB |
Output is correct |
66 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |