#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N= 1e5 + 5;
int n , k;
int A[N] , B[N] , C[N] , D[N];
int cnt[2];
int ans = 1e18;
void q(int x){
int sz = n / x;
for(int i = 0; i < k; ++i){
cnt[(B[i] /x + A[i] / x) % 2]++;
}
int bk = ((n*n / (x * x)) / 2) * x * x ,ok = 0;
if(sz % 2 == 1) ok = 1;
int Y = bk - cnt[1] + cnt[0];
ans = min(ans , Y);
bk = (((n * n) / (x * x)) - ((n*n / (x * x)) / 2)) * x * x;
Y = bk - cnt[0] + cnt[1];
ans = min(ans, Y);
cnt[0]=cnt[1]=0;
//cout << endl;
}
main (){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for(int i = 0; i < k; ++i){
cin >> A[i] >> B[i] >> C[i] >> D[i];
--A[i] , --B[i] , --C[i] , --D[i];
}//cout << endl;
for(int i = 1; i * i <=n; ++i){
if(n % i ==0){
if((n / i) != n)q(n/i);
if((n/i) != i)q(i);
}
}
cout << ans;
}
Compilation message
chessboard.cpp: In function 'void q(long long int)':
chessboard.cpp:14:45: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
14 | int bk = ((n*n / (x * x)) / 2) * x * x ,ok = 0;
| ^~
chessboard.cpp: At global scope:
chessboard.cpp:24:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
24 | main (){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2216 KB |
Output is correct |
2 |
Correct |
6 ms |
1104 KB |
Output is correct |
3 |
Correct |
12 ms |
2408 KB |
Output is correct |
4 |
Correct |
13 ms |
2512 KB |
Output is correct |
5 |
Correct |
19 ms |
3340 KB |
Output is correct |
6 |
Correct |
11 ms |
2232 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
8 |
Correct |
11 ms |
2256 KB |
Output is correct |
9 |
Correct |
28 ms |
5216 KB |
Output is correct |
10 |
Correct |
16 ms |
3028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
8 ms |
1616 KB |
Output is correct |
17 |
Correct |
21 ms |
4264 KB |
Output is correct |
18 |
Correct |
28 ms |
4948 KB |
Output is correct |
19 |
Correct |
51 ms |
4580 KB |
Output is correct |
20 |
Correct |
59 ms |
4912 KB |
Output is correct |
21 |
Correct |
22 ms |
4164 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
14 ms |
2260 KB |
Output is correct |
24 |
Correct |
27 ms |
4564 KB |
Output is correct |
25 |
Correct |
3 ms |
720 KB |
Output is correct |
26 |
Correct |
18 ms |
2940 KB |
Output is correct |
27 |
Correct |
22 ms |
3548 KB |
Output is correct |
28 |
Correct |
27 ms |
4776 KB |
Output is correct |
29 |
Correct |
8 ms |
1872 KB |
Output is correct |
30 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2216 KB |
Output is correct |
2 |
Correct |
6 ms |
1104 KB |
Output is correct |
3 |
Correct |
12 ms |
2408 KB |
Output is correct |
4 |
Correct |
13 ms |
2512 KB |
Output is correct |
5 |
Correct |
19 ms |
3340 KB |
Output is correct |
6 |
Correct |
11 ms |
2232 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
8 |
Correct |
11 ms |
2256 KB |
Output is correct |
9 |
Correct |
28 ms |
5216 KB |
Output is correct |
10 |
Correct |
16 ms |
3028 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
288 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
0 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
8 ms |
1616 KB |
Output is correct |
27 |
Correct |
21 ms |
4264 KB |
Output is correct |
28 |
Correct |
28 ms |
4948 KB |
Output is correct |
29 |
Correct |
51 ms |
4580 KB |
Output is correct |
30 |
Correct |
59 ms |
4912 KB |
Output is correct |
31 |
Correct |
22 ms |
4164 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
14 ms |
2260 KB |
Output is correct |
34 |
Correct |
27 ms |
4564 KB |
Output is correct |
35 |
Correct |
3 ms |
720 KB |
Output is correct |
36 |
Correct |
18 ms |
2940 KB |
Output is correct |
37 |
Correct |
22 ms |
3548 KB |
Output is correct |
38 |
Correct |
27 ms |
4776 KB |
Output is correct |
39 |
Correct |
8 ms |
1872 KB |
Output is correct |
40 |
Correct |
2 ms |
336 KB |
Output is correct |
41 |
Correct |
51 ms |
4892 KB |
Output is correct |
42 |
Correct |
34 ms |
5528 KB |
Output is correct |
43 |
Correct |
36 ms |
4820 KB |
Output is correct |
44 |
Correct |
29 ms |
5340 KB |
Output is correct |
45 |
Correct |
29 ms |
5700 KB |
Output is correct |
46 |
Correct |
59 ms |
5448 KB |
Output is correct |
47 |
Correct |
26 ms |
5072 KB |
Output is correct |
48 |
Correct |
34 ms |
5132 KB |
Output is correct |
49 |
Correct |
28 ms |
4840 KB |
Output is correct |
50 |
Correct |
184 ms |
5332 KB |
Output is correct |
51 |
Correct |
190 ms |
5576 KB |
Output is correct |
52 |
Correct |
179 ms |
5288 KB |
Output is correct |
53 |
Correct |
191 ms |
5576 KB |
Output is correct |
54 |
Correct |
180 ms |
5224 KB |
Output is correct |
55 |
Correct |
197 ms |
5704 KB |
Output is correct |
56 |
Correct |
175 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
18 ms |
2216 KB |
Output is correct |
10 |
Correct |
6 ms |
1104 KB |
Output is correct |
11 |
Correct |
12 ms |
2408 KB |
Output is correct |
12 |
Correct |
13 ms |
2512 KB |
Output is correct |
13 |
Correct |
19 ms |
3340 KB |
Output is correct |
14 |
Correct |
11 ms |
2232 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
11 ms |
2256 KB |
Output is correct |
17 |
Correct |
28 ms |
5216 KB |
Output is correct |
18 |
Correct |
16 ms |
3028 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
336 KB |
Output is correct |
21 |
Correct |
0 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
288 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
0 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
0 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
8 ms |
1616 KB |
Output is correct |
35 |
Correct |
21 ms |
4264 KB |
Output is correct |
36 |
Correct |
28 ms |
4948 KB |
Output is correct |
37 |
Correct |
51 ms |
4580 KB |
Output is correct |
38 |
Correct |
59 ms |
4912 KB |
Output is correct |
39 |
Correct |
22 ms |
4164 KB |
Output is correct |
40 |
Correct |
1 ms |
336 KB |
Output is correct |
41 |
Correct |
14 ms |
2260 KB |
Output is correct |
42 |
Correct |
27 ms |
4564 KB |
Output is correct |
43 |
Correct |
3 ms |
720 KB |
Output is correct |
44 |
Correct |
18 ms |
2940 KB |
Output is correct |
45 |
Correct |
22 ms |
3548 KB |
Output is correct |
46 |
Correct |
27 ms |
4776 KB |
Output is correct |
47 |
Correct |
8 ms |
1872 KB |
Output is correct |
48 |
Correct |
2 ms |
336 KB |
Output is correct |
49 |
Correct |
51 ms |
4892 KB |
Output is correct |
50 |
Correct |
34 ms |
5528 KB |
Output is correct |
51 |
Correct |
36 ms |
4820 KB |
Output is correct |
52 |
Correct |
29 ms |
5340 KB |
Output is correct |
53 |
Correct |
29 ms |
5700 KB |
Output is correct |
54 |
Correct |
59 ms |
5448 KB |
Output is correct |
55 |
Correct |
26 ms |
5072 KB |
Output is correct |
56 |
Correct |
34 ms |
5132 KB |
Output is correct |
57 |
Correct |
28 ms |
4840 KB |
Output is correct |
58 |
Correct |
184 ms |
5332 KB |
Output is correct |
59 |
Correct |
190 ms |
5576 KB |
Output is correct |
60 |
Correct |
179 ms |
5288 KB |
Output is correct |
61 |
Correct |
191 ms |
5576 KB |
Output is correct |
62 |
Correct |
180 ms |
5224 KB |
Output is correct |
63 |
Correct |
197 ms |
5704 KB |
Output is correct |
64 |
Correct |
175 ms |
5076 KB |
Output is correct |
65 |
Correct |
0 ms |
336 KB |
Output is correct |
66 |
Incorrect |
0 ms |
336 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |