#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long
struct rect{
int x1, y1, x2, y2;
};
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
rect a[k];
for(int i=0; i< k; i++){
cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
a[i].x1--;
a[i].x2--;
a[i].y1--;
a[i].y2--;
}
int ans=1e12;
for(int d=1; d<n; d++){
if(n%d!=0)continue;
int flip=d*d*(((n*n)/(d*d)+1)/2);
for(int i=0; i< k; i++){
if(((a[i].x1/d)&1)==((a[i].y1/d)&1)){
flip--;
}
else{
flip++;
}
}
ans=min({ans, flip, n*n-flip});
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
3672 KB |
Output is correct |
2 |
Correct |
4 ms |
1116 KB |
Output is correct |
3 |
Correct |
11 ms |
2564 KB |
Output is correct |
4 |
Correct |
11 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
3420 KB |
Output is correct |
6 |
Correct |
12 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Correct |
10 ms |
2140 KB |
Output is correct |
9 |
Correct |
26 ms |
5204 KB |
Output is correct |
10 |
Correct |
13 ms |
3164 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 |
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 |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
464 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 |
0 ms |
456 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 |
600 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 |
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 |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
464 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 |
0 ms |
456 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 |
600 KB |
Output is correct |
16 |
Correct |
7 ms |
1624 KB |
Output is correct |
17 |
Correct |
18 ms |
4444 KB |
Output is correct |
18 |
Correct |
23 ms |
4952 KB |
Output is correct |
19 |
Correct |
42 ms |
4444 KB |
Output is correct |
20 |
Correct |
45 ms |
5064 KB |
Output is correct |
21 |
Correct |
18 ms |
4184 KB |
Output is correct |
22 |
Correct |
0 ms |
476 KB |
Output is correct |
23 |
Correct |
12 ms |
2404 KB |
Output is correct |
24 |
Correct |
24 ms |
4696 KB |
Output is correct |
25 |
Correct |
3 ms |
856 KB |
Output is correct |
26 |
Correct |
14 ms |
2976 KB |
Output is correct |
27 |
Correct |
18 ms |
3676 KB |
Output is correct |
28 |
Correct |
22 ms |
4956 KB |
Output is correct |
29 |
Correct |
9 ms |
1880 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
3672 KB |
Output is correct |
2 |
Correct |
4 ms |
1116 KB |
Output is correct |
3 |
Correct |
11 ms |
2564 KB |
Output is correct |
4 |
Correct |
11 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
3420 KB |
Output is correct |
6 |
Correct |
12 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Correct |
10 ms |
2140 KB |
Output is correct |
9 |
Correct |
26 ms |
5204 KB |
Output is correct |
10 |
Correct |
13 ms |
3164 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
464 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 |
0 ms |
456 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 |
600 KB |
Output is correct |
26 |
Correct |
7 ms |
1624 KB |
Output is correct |
27 |
Correct |
18 ms |
4444 KB |
Output is correct |
28 |
Correct |
23 ms |
4952 KB |
Output is correct |
29 |
Correct |
42 ms |
4444 KB |
Output is correct |
30 |
Correct |
45 ms |
5064 KB |
Output is correct |
31 |
Correct |
18 ms |
4184 KB |
Output is correct |
32 |
Correct |
0 ms |
476 KB |
Output is correct |
33 |
Correct |
12 ms |
2404 KB |
Output is correct |
34 |
Correct |
24 ms |
4696 KB |
Output is correct |
35 |
Correct |
3 ms |
856 KB |
Output is correct |
36 |
Correct |
14 ms |
2976 KB |
Output is correct |
37 |
Correct |
18 ms |
3676 KB |
Output is correct |
38 |
Correct |
22 ms |
4956 KB |
Output is correct |
39 |
Correct |
9 ms |
1880 KB |
Output is correct |
40 |
Correct |
1 ms |
344 KB |
Output is correct |
41 |
Correct |
40 ms |
4956 KB |
Output is correct |
42 |
Correct |
27 ms |
5468 KB |
Output is correct |
43 |
Correct |
30 ms |
4820 KB |
Output is correct |
44 |
Correct |
25 ms |
5460 KB |
Output is correct |
45 |
Correct |
25 ms |
5668 KB |
Output is correct |
46 |
Correct |
45 ms |
5712 KB |
Output is correct |
47 |
Correct |
22 ms |
4956 KB |
Output is correct |
48 |
Correct |
28 ms |
5208 KB |
Output is correct |
49 |
Correct |
23 ms |
4952 KB |
Output is correct |
50 |
Correct |
143 ms |
5444 KB |
Output is correct |
51 |
Correct |
152 ms |
5724 KB |
Output is correct |
52 |
Correct |
142 ms |
5408 KB |
Output is correct |
53 |
Correct |
151 ms |
5736 KB |
Output is correct |
54 |
Correct |
140 ms |
5204 KB |
Output is correct |
55 |
Correct |
158 ms |
5712 KB |
Output is correct |
56 |
Correct |
137 ms |
5192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
3672 KB |
Output is correct |
10 |
Correct |
4 ms |
1116 KB |
Output is correct |
11 |
Correct |
11 ms |
2564 KB |
Output is correct |
12 |
Correct |
11 ms |
2652 KB |
Output is correct |
13 |
Correct |
14 ms |
3420 KB |
Output is correct |
14 |
Correct |
12 ms |
2652 KB |
Output is correct |
15 |
Correct |
2 ms |
600 KB |
Output is correct |
16 |
Correct |
10 ms |
2140 KB |
Output is correct |
17 |
Correct |
26 ms |
5204 KB |
Output is correct |
18 |
Correct |
13 ms |
3164 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
464 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 |
0 ms |
456 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 |
600 KB |
Output is correct |
34 |
Correct |
7 ms |
1624 KB |
Output is correct |
35 |
Correct |
18 ms |
4444 KB |
Output is correct |
36 |
Correct |
23 ms |
4952 KB |
Output is correct |
37 |
Correct |
42 ms |
4444 KB |
Output is correct |
38 |
Correct |
45 ms |
5064 KB |
Output is correct |
39 |
Correct |
18 ms |
4184 KB |
Output is correct |
40 |
Correct |
0 ms |
476 KB |
Output is correct |
41 |
Correct |
12 ms |
2404 KB |
Output is correct |
42 |
Correct |
24 ms |
4696 KB |
Output is correct |
43 |
Correct |
3 ms |
856 KB |
Output is correct |
44 |
Correct |
14 ms |
2976 KB |
Output is correct |
45 |
Correct |
18 ms |
3676 KB |
Output is correct |
46 |
Correct |
22 ms |
4956 KB |
Output is correct |
47 |
Correct |
9 ms |
1880 KB |
Output is correct |
48 |
Correct |
1 ms |
344 KB |
Output is correct |
49 |
Correct |
40 ms |
4956 KB |
Output is correct |
50 |
Correct |
27 ms |
5468 KB |
Output is correct |
51 |
Correct |
30 ms |
4820 KB |
Output is correct |
52 |
Correct |
25 ms |
5460 KB |
Output is correct |
53 |
Correct |
25 ms |
5668 KB |
Output is correct |
54 |
Correct |
45 ms |
5712 KB |
Output is correct |
55 |
Correct |
22 ms |
4956 KB |
Output is correct |
56 |
Correct |
28 ms |
5208 KB |
Output is correct |
57 |
Correct |
23 ms |
4952 KB |
Output is correct |
58 |
Correct |
143 ms |
5444 KB |
Output is correct |
59 |
Correct |
152 ms |
5724 KB |
Output is correct |
60 |
Correct |
142 ms |
5408 KB |
Output is correct |
61 |
Correct |
151 ms |
5736 KB |
Output is correct |
62 |
Correct |
140 ms |
5204 KB |
Output is correct |
63 |
Correct |
158 ms |
5712 KB |
Output is correct |
64 |
Correct |
137 ms |
5192 KB |
Output is correct |
65 |
Correct |
0 ms |
348 KB |
Output is correct |
66 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |