//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define sqr(x) (x) * (x)
using namespace std;
using namespace __gnu_pbds;
ll n, k;
vector <pair <pair <ll, ll>, pair <ll, ll>>> a;
ll ans;
void solve(ll l)
{
ll cnt = sqr(((n + l) / (2 * l)) * l);
cnt += sqr((n / (2 * l)) * l);
{
ll ot = cnt;
for(int i = 0; i < k; ++i)
{
ll x = a[i].F.F;
ll y = a[i].F.S;
if (((((x + l - 1) / l) % 2) ^ (((y + l - 1) / l) % 2)) == 0) --ot;
else ++ot;
}
ans = min(ans, ot);
}
{
ll ot = n * n - cnt;
for(int i = 0; i < k; ++i)
{
int x = a[i].F.F;
int y = a[i].F.S;
if (((((x + l - 1) / l) % 2) ^ (((y + l - 1) / l) % 2)) == 1) --ot;
else ++ot;
}
ans = min(ans, ot);
}
return;
}
int main()
{
#ifdef LOCAL
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
a.resize(k);
for(int i = 0; i < k; ++i)
{
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
a[i] = {{x1, y1}, {x2, y2}};
}
ans = n * n;
ll i;
for(i = 1; i * i < n; ++i)
{
if (n % i == 0)
{
solve(i);
if (i > 1) solve(n / i);
}
}
if (i * i == n) solve(i);
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
3832 KB |
Output is correct |
2 |
Correct |
11 ms |
1272 KB |
Output is correct |
3 |
Correct |
22 ms |
2556 KB |
Output is correct |
4 |
Correct |
24 ms |
2616 KB |
Output is correct |
5 |
Correct |
30 ms |
3384 KB |
Output is correct |
6 |
Correct |
20 ms |
2296 KB |
Output is correct |
7 |
Correct |
6 ms |
760 KB |
Output is correct |
8 |
Correct |
20 ms |
2320 KB |
Output is correct |
9 |
Correct |
49 ms |
5240 KB |
Output is correct |
10 |
Correct |
28 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
1656 KB |
Output is correct |
17 |
Correct |
38 ms |
4304 KB |
Output is correct |
18 |
Correct |
55 ms |
5112 KB |
Output is correct |
19 |
Correct |
176 ms |
4600 KB |
Output is correct |
20 |
Correct |
221 ms |
5112 KB |
Output is correct |
21 |
Correct |
39 ms |
4216 KB |
Output is correct |
22 |
Correct |
3 ms |
380 KB |
Output is correct |
23 |
Correct |
33 ms |
2296 KB |
Output is correct |
24 |
Correct |
50 ms |
4600 KB |
Output is correct |
25 |
Correct |
8 ms |
760 KB |
Output is correct |
26 |
Correct |
32 ms |
3064 KB |
Output is correct |
27 |
Correct |
45 ms |
3564 KB |
Output is correct |
28 |
Correct |
52 ms |
4856 KB |
Output is correct |
29 |
Correct |
16 ms |
1912 KB |
Output is correct |
30 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
3832 KB |
Output is correct |
2 |
Correct |
11 ms |
1272 KB |
Output is correct |
3 |
Correct |
22 ms |
2556 KB |
Output is correct |
4 |
Correct |
24 ms |
2616 KB |
Output is correct |
5 |
Correct |
30 ms |
3384 KB |
Output is correct |
6 |
Correct |
20 ms |
2296 KB |
Output is correct |
7 |
Correct |
6 ms |
760 KB |
Output is correct |
8 |
Correct |
20 ms |
2320 KB |
Output is correct |
9 |
Correct |
49 ms |
5240 KB |
Output is correct |
10 |
Correct |
28 ms |
3064 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
380 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
17 ms |
1656 KB |
Output is correct |
27 |
Correct |
38 ms |
4304 KB |
Output is correct |
28 |
Correct |
55 ms |
5112 KB |
Output is correct |
29 |
Correct |
176 ms |
4600 KB |
Output is correct |
30 |
Correct |
221 ms |
5112 KB |
Output is correct |
31 |
Correct |
39 ms |
4216 KB |
Output is correct |
32 |
Correct |
3 ms |
380 KB |
Output is correct |
33 |
Correct |
33 ms |
2296 KB |
Output is correct |
34 |
Correct |
50 ms |
4600 KB |
Output is correct |
35 |
Correct |
8 ms |
760 KB |
Output is correct |
36 |
Correct |
32 ms |
3064 KB |
Output is correct |
37 |
Correct |
45 ms |
3564 KB |
Output is correct |
38 |
Correct |
52 ms |
4856 KB |
Output is correct |
39 |
Correct |
16 ms |
1912 KB |
Output is correct |
40 |
Correct |
3 ms |
504 KB |
Output is correct |
41 |
Correct |
141 ms |
4984 KB |
Output is correct |
42 |
Correct |
59 ms |
5624 KB |
Output is correct |
43 |
Correct |
88 ms |
4984 KB |
Output is correct |
44 |
Correct |
57 ms |
5456 KB |
Output is correct |
45 |
Correct |
51 ms |
5752 KB |
Output is correct |
46 |
Correct |
155 ms |
5496 KB |
Output is correct |
47 |
Correct |
45 ms |
5112 KB |
Output is correct |
48 |
Correct |
72 ms |
5240 KB |
Output is correct |
49 |
Correct |
52 ms |
4984 KB |
Output is correct |
50 |
Correct |
652 ms |
5368 KB |
Output is correct |
51 |
Correct |
694 ms |
5752 KB |
Output is correct |
52 |
Correct |
640 ms |
5368 KB |
Output is correct |
53 |
Correct |
677 ms |
5624 KB |
Output is correct |
54 |
Correct |
627 ms |
5240 KB |
Output is correct |
55 |
Correct |
721 ms |
5880 KB |
Output is correct |
56 |
Correct |
612 ms |
5160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
33 ms |
3832 KB |
Output is correct |
10 |
Correct |
11 ms |
1272 KB |
Output is correct |
11 |
Correct |
22 ms |
2556 KB |
Output is correct |
12 |
Correct |
24 ms |
2616 KB |
Output is correct |
13 |
Correct |
30 ms |
3384 KB |
Output is correct |
14 |
Correct |
20 ms |
2296 KB |
Output is correct |
15 |
Correct |
6 ms |
760 KB |
Output is correct |
16 |
Correct |
20 ms |
2320 KB |
Output is correct |
17 |
Correct |
49 ms |
5240 KB |
Output is correct |
18 |
Correct |
28 ms |
3064 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
380 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
3 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
3 ms |
376 KB |
Output is correct |
34 |
Correct |
17 ms |
1656 KB |
Output is correct |
35 |
Correct |
38 ms |
4304 KB |
Output is correct |
36 |
Correct |
55 ms |
5112 KB |
Output is correct |
37 |
Correct |
176 ms |
4600 KB |
Output is correct |
38 |
Correct |
221 ms |
5112 KB |
Output is correct |
39 |
Correct |
39 ms |
4216 KB |
Output is correct |
40 |
Correct |
3 ms |
380 KB |
Output is correct |
41 |
Correct |
33 ms |
2296 KB |
Output is correct |
42 |
Correct |
50 ms |
4600 KB |
Output is correct |
43 |
Correct |
8 ms |
760 KB |
Output is correct |
44 |
Correct |
32 ms |
3064 KB |
Output is correct |
45 |
Correct |
45 ms |
3564 KB |
Output is correct |
46 |
Correct |
52 ms |
4856 KB |
Output is correct |
47 |
Correct |
16 ms |
1912 KB |
Output is correct |
48 |
Correct |
3 ms |
504 KB |
Output is correct |
49 |
Correct |
141 ms |
4984 KB |
Output is correct |
50 |
Correct |
59 ms |
5624 KB |
Output is correct |
51 |
Correct |
88 ms |
4984 KB |
Output is correct |
52 |
Correct |
57 ms |
5456 KB |
Output is correct |
53 |
Correct |
51 ms |
5752 KB |
Output is correct |
54 |
Correct |
155 ms |
5496 KB |
Output is correct |
55 |
Correct |
45 ms |
5112 KB |
Output is correct |
56 |
Correct |
72 ms |
5240 KB |
Output is correct |
57 |
Correct |
52 ms |
4984 KB |
Output is correct |
58 |
Correct |
652 ms |
5368 KB |
Output is correct |
59 |
Correct |
694 ms |
5752 KB |
Output is correct |
60 |
Correct |
640 ms |
5368 KB |
Output is correct |
61 |
Correct |
677 ms |
5624 KB |
Output is correct |
62 |
Correct |
627 ms |
5240 KB |
Output is correct |
63 |
Correct |
721 ms |
5880 KB |
Output is correct |
64 |
Correct |
612 ms |
5160 KB |
Output is correct |
65 |
Correct |
2 ms |
504 KB |
Output is correct |
66 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |