#include <bits/stdc++.h>
using namespace std;
#define int long long
const int NM = 1e5, inf = 1e18;
int N, K, x[NM+5], y[NM+5], ans = +inf;
int num[2];
void solve(int t){
num[0] = num[1] = 0;
for (int i = 1; i <= K; i++){
int blx = x[i]/t+(x[i]%t > 0), bly = y[i]/t+(y[i]%t > 0);
num[(blx+bly)%2]++;
}
int targ = t*t*(N*N/(t*t)/2);
ans = min(ans, abs(targ-num[1])+num[0]);
ans = min(ans, abs(N*N-targ-num[0])+num[1]);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> K;
for (int i = 1; i <= K; i++){
cin >> x[i] >> y[i] >> x[i] >> y[i];
}
for (int i = 1; i*i <= N; i++)
if (N%i == 0){
solve(i);
if (i > 1) solve(N/i);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1368 KB |
Output is correct |
2 |
Correct |
5 ms |
856 KB |
Output is correct |
3 |
Correct |
11 ms |
1884 KB |
Output is correct |
4 |
Correct |
12 ms |
1948 KB |
Output is correct |
5 |
Correct |
14 ms |
2396 KB |
Output is correct |
6 |
Correct |
9 ms |
1628 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
9 ms |
1628 KB |
Output is correct |
9 |
Correct |
23 ms |
3920 KB |
Output is correct |
10 |
Correct |
14 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
348 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 |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
348 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 |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
1116 KB |
Output is correct |
17 |
Correct |
18 ms |
3028 KB |
Output is correct |
18 |
Correct |
25 ms |
3708 KB |
Output is correct |
19 |
Correct |
41 ms |
3164 KB |
Output is correct |
20 |
Correct |
47 ms |
3588 KB |
Output is correct |
21 |
Correct |
19 ms |
2812 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
12 ms |
1712 KB |
Output is correct |
24 |
Correct |
22 ms |
3164 KB |
Output is correct |
25 |
Correct |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
13 ms |
2128 KB |
Output is correct |
27 |
Correct |
20 ms |
2556 KB |
Output is correct |
28 |
Correct |
22 ms |
3412 KB |
Output is correct |
29 |
Correct |
8 ms |
1368 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1368 KB |
Output is correct |
2 |
Correct |
5 ms |
856 KB |
Output is correct |
3 |
Correct |
11 ms |
1884 KB |
Output is correct |
4 |
Correct |
12 ms |
1948 KB |
Output is correct |
5 |
Correct |
14 ms |
2396 KB |
Output is correct |
6 |
Correct |
9 ms |
1628 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
9 ms |
1628 KB |
Output is correct |
9 |
Correct |
23 ms |
3920 KB |
Output is correct |
10 |
Correct |
14 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
600 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 |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 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 |
348 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 |
348 KB |
Output is correct |
26 |
Correct |
7 ms |
1116 KB |
Output is correct |
27 |
Correct |
18 ms |
3028 KB |
Output is correct |
28 |
Correct |
25 ms |
3708 KB |
Output is correct |
29 |
Correct |
41 ms |
3164 KB |
Output is correct |
30 |
Correct |
47 ms |
3588 KB |
Output is correct |
31 |
Correct |
19 ms |
2812 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
12 ms |
1712 KB |
Output is correct |
34 |
Correct |
22 ms |
3164 KB |
Output is correct |
35 |
Correct |
3 ms |
600 KB |
Output is correct |
36 |
Correct |
13 ms |
2128 KB |
Output is correct |
37 |
Correct |
20 ms |
2556 KB |
Output is correct |
38 |
Correct |
22 ms |
3412 KB |
Output is correct |
39 |
Correct |
8 ms |
1368 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
40 ms |
3668 KB |
Output is correct |
42 |
Correct |
25 ms |
3932 KB |
Output is correct |
43 |
Correct |
30 ms |
3668 KB |
Output is correct |
44 |
Correct |
26 ms |
3928 KB |
Output is correct |
45 |
Correct |
32 ms |
4176 KB |
Output is correct |
46 |
Correct |
45 ms |
3920 KB |
Output is correct |
47 |
Correct |
23 ms |
3664 KB |
Output is correct |
48 |
Correct |
27 ms |
3664 KB |
Output is correct |
49 |
Correct |
23 ms |
3772 KB |
Output is correct |
50 |
Correct |
144 ms |
4032 KB |
Output is correct |
51 |
Correct |
151 ms |
4272 KB |
Output is correct |
52 |
Correct |
144 ms |
4000 KB |
Output is correct |
53 |
Correct |
155 ms |
4240 KB |
Output is correct |
54 |
Correct |
141 ms |
3916 KB |
Output is correct |
55 |
Correct |
159 ms |
4388 KB |
Output is correct |
56 |
Correct |
136 ms |
3852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
15 ms |
1368 KB |
Output is correct |
10 |
Correct |
5 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1884 KB |
Output is correct |
12 |
Correct |
12 ms |
1948 KB |
Output is correct |
13 |
Correct |
14 ms |
2396 KB |
Output is correct |
14 |
Correct |
9 ms |
1628 KB |
Output is correct |
15 |
Correct |
3 ms |
604 KB |
Output is correct |
16 |
Correct |
9 ms |
1628 KB |
Output is correct |
17 |
Correct |
23 ms |
3920 KB |
Output is correct |
18 |
Correct |
14 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
600 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 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 |
348 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 |
348 KB |
Output is correct |
34 |
Correct |
7 ms |
1116 KB |
Output is correct |
35 |
Correct |
18 ms |
3028 KB |
Output is correct |
36 |
Correct |
25 ms |
3708 KB |
Output is correct |
37 |
Correct |
41 ms |
3164 KB |
Output is correct |
38 |
Correct |
47 ms |
3588 KB |
Output is correct |
39 |
Correct |
19 ms |
2812 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
12 ms |
1712 KB |
Output is correct |
42 |
Correct |
22 ms |
3164 KB |
Output is correct |
43 |
Correct |
3 ms |
600 KB |
Output is correct |
44 |
Correct |
13 ms |
2128 KB |
Output is correct |
45 |
Correct |
20 ms |
2556 KB |
Output is correct |
46 |
Correct |
22 ms |
3412 KB |
Output is correct |
47 |
Correct |
8 ms |
1368 KB |
Output is correct |
48 |
Correct |
1 ms |
348 KB |
Output is correct |
49 |
Correct |
40 ms |
3668 KB |
Output is correct |
50 |
Correct |
25 ms |
3932 KB |
Output is correct |
51 |
Correct |
30 ms |
3668 KB |
Output is correct |
52 |
Correct |
26 ms |
3928 KB |
Output is correct |
53 |
Correct |
32 ms |
4176 KB |
Output is correct |
54 |
Correct |
45 ms |
3920 KB |
Output is correct |
55 |
Correct |
23 ms |
3664 KB |
Output is correct |
56 |
Correct |
27 ms |
3664 KB |
Output is correct |
57 |
Correct |
23 ms |
3772 KB |
Output is correct |
58 |
Correct |
144 ms |
4032 KB |
Output is correct |
59 |
Correct |
151 ms |
4272 KB |
Output is correct |
60 |
Correct |
144 ms |
4000 KB |
Output is correct |
61 |
Correct |
155 ms |
4240 KB |
Output is correct |
62 |
Correct |
141 ms |
3916 KB |
Output is correct |
63 |
Correct |
159 ms |
4388 KB |
Output is correct |
64 |
Correct |
136 ms |
3852 KB |
Output is correct |
65 |
Correct |
1 ms |
348 KB |
Output is correct |
66 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |