//-------------dilanyan------------\\
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//------------------KarginDefines--------------------\\
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
//-------------------KarginConstants------------------\\
const ll mod = 1000000007;
const ll inf = 1e12;
//-------------------KarginCode------------------------\\
const int N = 100005;
ll x[N], y[N];
void KarginSolve() {
ll n, k;
cin >> n >> k;
ll sq = sqrt(n);
vector<ll> div;
for (ll i = 1;i <= sq;i++) {
if (n % i == 0) {
div.pb(i);
if (i * i != n) div.pb(n / i);
}
}
for (int i = 0;i < k;i++) cin >> x[i] >> y[i] >> x[i] >> y[i];
ll ans = inf;
for (ll d : div) {
if (d == n) continue;
ll c = (n * n) / (d * d);
ll fw = c / 2, fb = (c + 1) / 2;
fw = fw * d * d, fb = fb * d * d;
for (int i = 0;i < k;i++) {
ll dx = (x[i] + d - 1) / d, dy = (y[i] + d - 1) / d;
if (dx & 1) {
if (dy & 1) fw++, fb--;
else fw--, fb++;
}
else {
if (dy & 1) fw--, fb++;
else fw++, fb--;
}
}
ans = min(ans, min(fw, fb));
}
cout << ans << '\n';
}
int main() {
//Usaco
Kargin;
int test = 1;
//cin >> test;
while (test--) {
KarginSolve();
}
return 0;
}
Compilation message
chessboard.cpp:1:1: warning: multi-line comment [-Wcomment]
1 | //-------------dilanyan------------\\
| ^
chessboard.cpp:8:1: warning: multi-line comment [-Wcomment]
8 | //------------------KarginDefines--------------------\\
| ^
chessboard.cpp:22:1: warning: multi-line comment [-Wcomment]
22 | //-------------------KarginConstants------------------\\
| ^
chessboard.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | //-------------------KarginCode------------------------\\
| ^
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
460 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 |
17 ms |
2896 KB |
Output is correct |
2 |
Correct |
5 ms |
860 KB |
Output is correct |
3 |
Correct |
13 ms |
1928 KB |
Output is correct |
4 |
Correct |
12 ms |
1880 KB |
Output is correct |
5 |
Correct |
14 ms |
2396 KB |
Output is correct |
6 |
Correct |
10 ms |
1680 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
10 ms |
1712 KB |
Output is correct |
9 |
Correct |
25 ms |
3896 KB |
Output is correct |
10 |
Correct |
13 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 |
348 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 |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
1116 KB |
Output is correct |
17 |
Correct |
19 ms |
3112 KB |
Output is correct |
18 |
Correct |
25 ms |
3408 KB |
Output is correct |
19 |
Correct |
53 ms |
3160 KB |
Output is correct |
20 |
Correct |
59 ms |
3528 KB |
Output is correct |
21 |
Correct |
21 ms |
2904 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
13 ms |
1628 KB |
Output is correct |
24 |
Correct |
22 ms |
3336 KB |
Output is correct |
25 |
Correct |
4 ms |
588 KB |
Output is correct |
26 |
Correct |
16 ms |
2132 KB |
Output is correct |
27 |
Correct |
19 ms |
2604 KB |
Output is correct |
28 |
Correct |
23 ms |
3408 KB |
Output is correct |
29 |
Correct |
10 ms |
1508 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2896 KB |
Output is correct |
2 |
Correct |
5 ms |
860 KB |
Output is correct |
3 |
Correct |
13 ms |
1928 KB |
Output is correct |
4 |
Correct |
12 ms |
1880 KB |
Output is correct |
5 |
Correct |
14 ms |
2396 KB |
Output is correct |
6 |
Correct |
10 ms |
1680 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
10 ms |
1712 KB |
Output is correct |
9 |
Correct |
25 ms |
3896 KB |
Output is correct |
10 |
Correct |
13 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 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 |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
8 ms |
1116 KB |
Output is correct |
27 |
Correct |
19 ms |
3112 KB |
Output is correct |
28 |
Correct |
25 ms |
3408 KB |
Output is correct |
29 |
Correct |
53 ms |
3160 KB |
Output is correct |
30 |
Correct |
59 ms |
3528 KB |
Output is correct |
31 |
Correct |
21 ms |
2904 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
13 ms |
1628 KB |
Output is correct |
34 |
Correct |
22 ms |
3336 KB |
Output is correct |
35 |
Correct |
4 ms |
588 KB |
Output is correct |
36 |
Correct |
16 ms |
2132 KB |
Output is correct |
37 |
Correct |
19 ms |
2604 KB |
Output is correct |
38 |
Correct |
23 ms |
3408 KB |
Output is correct |
39 |
Correct |
10 ms |
1508 KB |
Output is correct |
40 |
Correct |
1 ms |
344 KB |
Output is correct |
41 |
Correct |
50 ms |
3624 KB |
Output is correct |
42 |
Correct |
31 ms |
4684 KB |
Output is correct |
43 |
Correct |
34 ms |
3600 KB |
Output is correct |
44 |
Correct |
26 ms |
3896 KB |
Output is correct |
45 |
Correct |
26 ms |
4188 KB |
Output is correct |
46 |
Correct |
56 ms |
3952 KB |
Output is correct |
47 |
Correct |
24 ms |
3664 KB |
Output is correct |
48 |
Correct |
30 ms |
3664 KB |
Output is correct |
49 |
Correct |
25 ms |
3664 KB |
Output is correct |
50 |
Correct |
200 ms |
3924 KB |
Output is correct |
51 |
Correct |
212 ms |
4180 KB |
Output is correct |
52 |
Correct |
198 ms |
4016 KB |
Output is correct |
53 |
Correct |
214 ms |
4324 KB |
Output is correct |
54 |
Correct |
196 ms |
3964 KB |
Output is correct |
55 |
Correct |
220 ms |
4180 KB |
Output is correct |
56 |
Correct |
189 ms |
3668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
460 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
2896 KB |
Output is correct |
10 |
Correct |
5 ms |
860 KB |
Output is correct |
11 |
Correct |
13 ms |
1928 KB |
Output is correct |
12 |
Correct |
12 ms |
1880 KB |
Output is correct |
13 |
Correct |
14 ms |
2396 KB |
Output is correct |
14 |
Correct |
10 ms |
1680 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
10 ms |
1712 KB |
Output is correct |
17 |
Correct |
25 ms |
3896 KB |
Output is correct |
18 |
Correct |
13 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
8 ms |
1116 KB |
Output is correct |
35 |
Correct |
19 ms |
3112 KB |
Output is correct |
36 |
Correct |
25 ms |
3408 KB |
Output is correct |
37 |
Correct |
53 ms |
3160 KB |
Output is correct |
38 |
Correct |
59 ms |
3528 KB |
Output is correct |
39 |
Correct |
21 ms |
2904 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
13 ms |
1628 KB |
Output is correct |
42 |
Correct |
22 ms |
3336 KB |
Output is correct |
43 |
Correct |
4 ms |
588 KB |
Output is correct |
44 |
Correct |
16 ms |
2132 KB |
Output is correct |
45 |
Correct |
19 ms |
2604 KB |
Output is correct |
46 |
Correct |
23 ms |
3408 KB |
Output is correct |
47 |
Correct |
10 ms |
1508 KB |
Output is correct |
48 |
Correct |
1 ms |
344 KB |
Output is correct |
49 |
Correct |
50 ms |
3624 KB |
Output is correct |
50 |
Correct |
31 ms |
4684 KB |
Output is correct |
51 |
Correct |
34 ms |
3600 KB |
Output is correct |
52 |
Correct |
26 ms |
3896 KB |
Output is correct |
53 |
Correct |
26 ms |
4188 KB |
Output is correct |
54 |
Correct |
56 ms |
3952 KB |
Output is correct |
55 |
Correct |
24 ms |
3664 KB |
Output is correct |
56 |
Correct |
30 ms |
3664 KB |
Output is correct |
57 |
Correct |
25 ms |
3664 KB |
Output is correct |
58 |
Correct |
200 ms |
3924 KB |
Output is correct |
59 |
Correct |
212 ms |
4180 KB |
Output is correct |
60 |
Correct |
198 ms |
4016 KB |
Output is correct |
61 |
Correct |
214 ms |
4324 KB |
Output is correct |
62 |
Correct |
196 ms |
3964 KB |
Output is correct |
63 |
Correct |
220 ms |
4180 KB |
Output is correct |
64 |
Correct |
189 ms |
3668 KB |
Output is correct |
65 |
Correct |
0 ms |
348 KB |
Output is correct |
66 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |