#include <bits/stdc++.h>
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) (x.begin(), x.end())
#define pb push_back
#define int long long
typedef long long ll;
using namespace std;
const int N = 1e5 + 11;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 11;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll n, m;
ll ax[N], bx[N], ay[N], by[N];
vector < ll > d;
bool check(ll x, ll y, ll sz){
ll a = x % (sz * 2);
ll b = y % (sz * 2);
a = bool(1 <= a && a <= sz);
b = bool(1 <= b && b <= sz);
// cout << x << ' ' << y << ' ' << a << ' ' << b << ' ' << sz << ' ' << ((a + b) & 1) << '\n';
return ((a + b) & 1);
}
void solve(){
cin >> n >> m;
for(int i = 1; i <= m; i++) cin >> ax[i] >> ay[i] >> bx[i] >> by[i];
for(int i = 1; i < n; i++){
if(n % i == 0){
d.pb(i);
}
}
ll mn = inf;
for(int sz : d){
ll cur1 = ((n / sz) * (n / sz) / 2) * (sz * sz);
ll cur2 = ((n / sz) * (n / sz) - ((n / sz) * (n / sz) / 2)) * (sz * sz);
cur1 -= m, cur2 -= m;
for(int i = 1; i <= m; i++){
if(!check(ax[i], ay[i], sz)) cur1 += 2;
else cur2 += 2;
}
// cout << sz << ' ' << cur1 << ' ' << cur2 << '\n';
mn = min(mn, min(cur1, cur2));
}
cout << mn;
}
const bool Cases = 0;
signed main(){
adiyer();
int CS = 1;
if(Cases) cin >> CS;
while(CS--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
4688 KB |
Output is correct |
2 |
Correct |
6 ms |
2896 KB |
Output is correct |
3 |
Correct |
11 ms |
3960 KB |
Output is correct |
4 |
Correct |
13 ms |
3932 KB |
Output is correct |
5 |
Correct |
15 ms |
4432 KB |
Output is correct |
6 |
Correct |
10 ms |
3664 KB |
Output is correct |
7 |
Correct |
3 ms |
2640 KB |
Output is correct |
8 |
Correct |
10 ms |
3752 KB |
Output is correct |
9 |
Correct |
23 ms |
5448 KB |
Output is correct |
10 |
Correct |
13 ms |
4176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2556 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2388 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2524 KB |
Output is correct |
10 |
Correct |
1 ms |
2528 KB |
Output is correct |
11 |
Correct |
2 ms |
2548 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2552 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2556 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2388 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2524 KB |
Output is correct |
10 |
Correct |
1 ms |
2528 KB |
Output is correct |
11 |
Correct |
2 ms |
2548 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2552 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
2 ms |
2652 KB |
Output is correct |
16 |
Correct |
7 ms |
3316 KB |
Output is correct |
17 |
Correct |
16 ms |
4688 KB |
Output is correct |
18 |
Correct |
20 ms |
4944 KB |
Output is correct |
19 |
Correct |
42 ms |
4688 KB |
Output is correct |
20 |
Correct |
46 ms |
4988 KB |
Output is correct |
21 |
Correct |
16 ms |
4432 KB |
Output is correct |
22 |
Correct |
1 ms |
2384 KB |
Output is correct |
23 |
Correct |
11 ms |
3664 KB |
Output is correct |
24 |
Correct |
18 ms |
4760 KB |
Output is correct |
25 |
Correct |
3 ms |
2640 KB |
Output is correct |
26 |
Correct |
12 ms |
3920 KB |
Output is correct |
27 |
Correct |
20 ms |
4176 KB |
Output is correct |
28 |
Correct |
20 ms |
4944 KB |
Output is correct |
29 |
Correct |
7 ms |
3408 KB |
Output is correct |
30 |
Correct |
2 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
4688 KB |
Output is correct |
2 |
Correct |
6 ms |
2896 KB |
Output is correct |
3 |
Correct |
11 ms |
3960 KB |
Output is correct |
4 |
Correct |
13 ms |
3932 KB |
Output is correct |
5 |
Correct |
15 ms |
4432 KB |
Output is correct |
6 |
Correct |
10 ms |
3664 KB |
Output is correct |
7 |
Correct |
3 ms |
2640 KB |
Output is correct |
8 |
Correct |
10 ms |
3752 KB |
Output is correct |
9 |
Correct |
23 ms |
5448 KB |
Output is correct |
10 |
Correct |
13 ms |
4176 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2556 KB |
Output is correct |
16 |
Correct |
1 ms |
2384 KB |
Output is correct |
17 |
Correct |
1 ms |
2388 KB |
Output is correct |
18 |
Correct |
1 ms |
2384 KB |
Output is correct |
19 |
Correct |
1 ms |
2524 KB |
Output is correct |
20 |
Correct |
1 ms |
2528 KB |
Output is correct |
21 |
Correct |
2 ms |
2548 KB |
Output is correct |
22 |
Correct |
1 ms |
2384 KB |
Output is correct |
23 |
Correct |
1 ms |
2552 KB |
Output is correct |
24 |
Correct |
1 ms |
2384 KB |
Output is correct |
25 |
Correct |
2 ms |
2652 KB |
Output is correct |
26 |
Correct |
7 ms |
3316 KB |
Output is correct |
27 |
Correct |
16 ms |
4688 KB |
Output is correct |
28 |
Correct |
20 ms |
4944 KB |
Output is correct |
29 |
Correct |
42 ms |
4688 KB |
Output is correct |
30 |
Correct |
46 ms |
4988 KB |
Output is correct |
31 |
Correct |
16 ms |
4432 KB |
Output is correct |
32 |
Correct |
1 ms |
2384 KB |
Output is correct |
33 |
Correct |
11 ms |
3664 KB |
Output is correct |
34 |
Correct |
18 ms |
4760 KB |
Output is correct |
35 |
Correct |
3 ms |
2640 KB |
Output is correct |
36 |
Correct |
12 ms |
3920 KB |
Output is correct |
37 |
Correct |
20 ms |
4176 KB |
Output is correct |
38 |
Correct |
20 ms |
4944 KB |
Output is correct |
39 |
Correct |
7 ms |
3408 KB |
Output is correct |
40 |
Correct |
2 ms |
2384 KB |
Output is correct |
41 |
Correct |
37 ms |
5200 KB |
Output is correct |
42 |
Correct |
24 ms |
5872 KB |
Output is correct |
43 |
Correct |
31 ms |
5200 KB |
Output is correct |
44 |
Correct |
26 ms |
5456 KB |
Output is correct |
45 |
Correct |
25 ms |
5728 KB |
Output is correct |
46 |
Correct |
42 ms |
5588 KB |
Output is correct |
47 |
Correct |
22 ms |
5368 KB |
Output is correct |
48 |
Correct |
25 ms |
5456 KB |
Output is correct |
49 |
Correct |
21 ms |
5200 KB |
Output is correct |
50 |
Correct |
132 ms |
5628 KB |
Output is correct |
51 |
Correct |
147 ms |
5716 KB |
Output is correct |
52 |
Correct |
133 ms |
5456 KB |
Output is correct |
53 |
Correct |
143 ms |
5724 KB |
Output is correct |
54 |
Correct |
134 ms |
5456 KB |
Output is correct |
55 |
Correct |
151 ms |
5960 KB |
Output is correct |
56 |
Correct |
134 ms |
5416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
18 ms |
4688 KB |
Output is correct |
10 |
Correct |
6 ms |
2896 KB |
Output is correct |
11 |
Correct |
11 ms |
3960 KB |
Output is correct |
12 |
Correct |
13 ms |
3932 KB |
Output is correct |
13 |
Correct |
15 ms |
4432 KB |
Output is correct |
14 |
Correct |
10 ms |
3664 KB |
Output is correct |
15 |
Correct |
3 ms |
2640 KB |
Output is correct |
16 |
Correct |
10 ms |
3752 KB |
Output is correct |
17 |
Correct |
23 ms |
5448 KB |
Output is correct |
18 |
Correct |
13 ms |
4176 KB |
Output is correct |
19 |
Correct |
1 ms |
2384 KB |
Output is correct |
20 |
Correct |
1 ms |
2384 KB |
Output is correct |
21 |
Correct |
1 ms |
2384 KB |
Output is correct |
22 |
Correct |
1 ms |
2384 KB |
Output is correct |
23 |
Correct |
1 ms |
2556 KB |
Output is correct |
24 |
Correct |
1 ms |
2384 KB |
Output is correct |
25 |
Correct |
1 ms |
2388 KB |
Output is correct |
26 |
Correct |
1 ms |
2384 KB |
Output is correct |
27 |
Correct |
1 ms |
2524 KB |
Output is correct |
28 |
Correct |
1 ms |
2528 KB |
Output is correct |
29 |
Correct |
2 ms |
2548 KB |
Output is correct |
30 |
Correct |
1 ms |
2384 KB |
Output is correct |
31 |
Correct |
1 ms |
2552 KB |
Output is correct |
32 |
Correct |
1 ms |
2384 KB |
Output is correct |
33 |
Correct |
2 ms |
2652 KB |
Output is correct |
34 |
Correct |
7 ms |
3316 KB |
Output is correct |
35 |
Correct |
16 ms |
4688 KB |
Output is correct |
36 |
Correct |
20 ms |
4944 KB |
Output is correct |
37 |
Correct |
42 ms |
4688 KB |
Output is correct |
38 |
Correct |
46 ms |
4988 KB |
Output is correct |
39 |
Correct |
16 ms |
4432 KB |
Output is correct |
40 |
Correct |
1 ms |
2384 KB |
Output is correct |
41 |
Correct |
11 ms |
3664 KB |
Output is correct |
42 |
Correct |
18 ms |
4760 KB |
Output is correct |
43 |
Correct |
3 ms |
2640 KB |
Output is correct |
44 |
Correct |
12 ms |
3920 KB |
Output is correct |
45 |
Correct |
20 ms |
4176 KB |
Output is correct |
46 |
Correct |
20 ms |
4944 KB |
Output is correct |
47 |
Correct |
7 ms |
3408 KB |
Output is correct |
48 |
Correct |
2 ms |
2384 KB |
Output is correct |
49 |
Correct |
37 ms |
5200 KB |
Output is correct |
50 |
Correct |
24 ms |
5872 KB |
Output is correct |
51 |
Correct |
31 ms |
5200 KB |
Output is correct |
52 |
Correct |
26 ms |
5456 KB |
Output is correct |
53 |
Correct |
25 ms |
5728 KB |
Output is correct |
54 |
Correct |
42 ms |
5588 KB |
Output is correct |
55 |
Correct |
22 ms |
5368 KB |
Output is correct |
56 |
Correct |
25 ms |
5456 KB |
Output is correct |
57 |
Correct |
21 ms |
5200 KB |
Output is correct |
58 |
Correct |
132 ms |
5628 KB |
Output is correct |
59 |
Correct |
147 ms |
5716 KB |
Output is correct |
60 |
Correct |
133 ms |
5456 KB |
Output is correct |
61 |
Correct |
143 ms |
5724 KB |
Output is correct |
62 |
Correct |
134 ms |
5456 KB |
Output is correct |
63 |
Correct |
151 ms |
5960 KB |
Output is correct |
64 |
Correct |
134 ms |
5416 KB |
Output is correct |
65 |
Correct |
1 ms |
2384 KB |
Output is correct |
66 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |