#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
ll ans,n,k,x[200005],y[200005];
void solve(ll t){
if(t == n)return;
ll raod = 0;
for(int i=1; i<=k; i++)
if((x[i] / t + y[i] / t) % 2 == 0)raod++;
if((n / t) % 2 == 0){
raod = max(raod , k - raod);
ans = min(ans , ((n * n) / 2) - raod + k - raod);
}
else{
ll fir = (((n/t)*(n/t))/2 + 1) * (t * t) - raod + (k - raod);
ll sec = (((n/t)*(n/t))/2) * (t * t) - (k - raod) + raod;
ans = min(ans , min(fir , sec));
}
}
int main(){
ios::sync_with_stdio(false);
cin >> n >> k;
for(int i=1; i<=k; i++){
cin >> x[i] >> y[i] >> x[i] >> y[i];
x[i]--;
y[i]--;
}
ans = n * n;
for(int i=1; i<=sqrt(n); i++){
if((n % i) == 0){
solve(n / i);
solve(i);
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
2168 KB |
Output is correct |
2 |
Correct |
10 ms |
988 KB |
Output is correct |
3 |
Correct |
21 ms |
1956 KB |
Output is correct |
4 |
Correct |
22 ms |
1784 KB |
Output is correct |
5 |
Correct |
28 ms |
2524 KB |
Output is correct |
6 |
Correct |
19 ms |
1784 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
19 ms |
1784 KB |
Output is correct |
9 |
Correct |
46 ms |
3356 KB |
Output is correct |
10 |
Correct |
26 ms |
2296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 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 |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
380 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 |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 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 |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
380 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 |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
14 ms |
1272 KB |
Output is correct |
17 |
Correct |
35 ms |
3024 KB |
Output is correct |
18 |
Correct |
46 ms |
3092 KB |
Output is correct |
19 |
Correct |
91 ms |
3064 KB |
Output is correct |
20 |
Correct |
101 ms |
3268 KB |
Output is correct |
21 |
Correct |
34 ms |
2944 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
25 ms |
1784 KB |
Output is correct |
24 |
Correct |
42 ms |
3080 KB |
Output is correct |
25 |
Correct |
7 ms |
632 KB |
Output is correct |
26 |
Correct |
27 ms |
2172 KB |
Output is correct |
27 |
Correct |
35 ms |
2552 KB |
Output is correct |
28 |
Correct |
46 ms |
3064 KB |
Output is correct |
29 |
Correct |
15 ms |
1400 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
2168 KB |
Output is correct |
2 |
Correct |
10 ms |
988 KB |
Output is correct |
3 |
Correct |
21 ms |
1956 KB |
Output is correct |
4 |
Correct |
22 ms |
1784 KB |
Output is correct |
5 |
Correct |
28 ms |
2524 KB |
Output is correct |
6 |
Correct |
19 ms |
1784 KB |
Output is correct |
7 |
Correct |
6 ms |
632 KB |
Output is correct |
8 |
Correct |
19 ms |
1784 KB |
Output is correct |
9 |
Correct |
46 ms |
3356 KB |
Output is correct |
10 |
Correct |
26 ms |
2296 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 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 |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
380 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
14 ms |
1272 KB |
Output is correct |
27 |
Correct |
35 ms |
3024 KB |
Output is correct |
28 |
Correct |
46 ms |
3092 KB |
Output is correct |
29 |
Correct |
91 ms |
3064 KB |
Output is correct |
30 |
Correct |
101 ms |
3268 KB |
Output is correct |
31 |
Correct |
34 ms |
2944 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
25 ms |
1784 KB |
Output is correct |
34 |
Correct |
42 ms |
3080 KB |
Output is correct |
35 |
Correct |
7 ms |
632 KB |
Output is correct |
36 |
Correct |
27 ms |
2172 KB |
Output is correct |
37 |
Correct |
35 ms |
2552 KB |
Output is correct |
38 |
Correct |
46 ms |
3064 KB |
Output is correct |
39 |
Correct |
15 ms |
1400 KB |
Output is correct |
40 |
Correct |
3 ms |
376 KB |
Output is correct |
41 |
Correct |
83 ms |
2808 KB |
Output is correct |
42 |
Correct |
50 ms |
2908 KB |
Output is correct |
43 |
Correct |
61 ms |
2808 KB |
Output is correct |
44 |
Correct |
49 ms |
2936 KB |
Output is correct |
45 |
Correct |
48 ms |
3064 KB |
Output is correct |
46 |
Correct |
93 ms |
2936 KB |
Output is correct |
47 |
Correct |
42 ms |
2808 KB |
Output is correct |
48 |
Correct |
55 ms |
2896 KB |
Output is correct |
49 |
Correct |
45 ms |
2808 KB |
Output is correct |
50 |
Correct |
313 ms |
3004 KB |
Output is correct |
51 |
Correct |
333 ms |
3192 KB |
Output is correct |
52 |
Correct |
310 ms |
2936 KB |
Output is correct |
53 |
Correct |
332 ms |
3068 KB |
Output is correct |
54 |
Correct |
309 ms |
3064 KB |
Output is correct |
55 |
Correct |
344 ms |
3064 KB |
Output is correct |
56 |
Correct |
298 ms |
2936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 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 |
32 ms |
2168 KB |
Output is correct |
10 |
Correct |
10 ms |
988 KB |
Output is correct |
11 |
Correct |
21 ms |
1956 KB |
Output is correct |
12 |
Correct |
22 ms |
1784 KB |
Output is correct |
13 |
Correct |
28 ms |
2524 KB |
Output is correct |
14 |
Correct |
19 ms |
1784 KB |
Output is correct |
15 |
Correct |
6 ms |
632 KB |
Output is correct |
16 |
Correct |
19 ms |
1784 KB |
Output is correct |
17 |
Correct |
46 ms |
3356 KB |
Output is correct |
18 |
Correct |
26 ms |
2296 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
380 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
380 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
14 ms |
1272 KB |
Output is correct |
35 |
Correct |
35 ms |
3024 KB |
Output is correct |
36 |
Correct |
46 ms |
3092 KB |
Output is correct |
37 |
Correct |
91 ms |
3064 KB |
Output is correct |
38 |
Correct |
101 ms |
3268 KB |
Output is correct |
39 |
Correct |
34 ms |
2944 KB |
Output is correct |
40 |
Correct |
2 ms |
376 KB |
Output is correct |
41 |
Correct |
25 ms |
1784 KB |
Output is correct |
42 |
Correct |
42 ms |
3080 KB |
Output is correct |
43 |
Correct |
7 ms |
632 KB |
Output is correct |
44 |
Correct |
27 ms |
2172 KB |
Output is correct |
45 |
Correct |
35 ms |
2552 KB |
Output is correct |
46 |
Correct |
46 ms |
3064 KB |
Output is correct |
47 |
Correct |
15 ms |
1400 KB |
Output is correct |
48 |
Correct |
3 ms |
376 KB |
Output is correct |
49 |
Correct |
83 ms |
2808 KB |
Output is correct |
50 |
Correct |
50 ms |
2908 KB |
Output is correct |
51 |
Correct |
61 ms |
2808 KB |
Output is correct |
52 |
Correct |
49 ms |
2936 KB |
Output is correct |
53 |
Correct |
48 ms |
3064 KB |
Output is correct |
54 |
Correct |
93 ms |
2936 KB |
Output is correct |
55 |
Correct |
42 ms |
2808 KB |
Output is correct |
56 |
Correct |
55 ms |
2896 KB |
Output is correct |
57 |
Correct |
45 ms |
2808 KB |
Output is correct |
58 |
Correct |
313 ms |
3004 KB |
Output is correct |
59 |
Correct |
333 ms |
3192 KB |
Output is correct |
60 |
Correct |
310 ms |
2936 KB |
Output is correct |
61 |
Correct |
332 ms |
3068 KB |
Output is correct |
62 |
Correct |
309 ms |
3064 KB |
Output is correct |
63 |
Correct |
344 ms |
3064 KB |
Output is correct |
64 |
Correct |
298 ms |
2936 KB |
Output is correct |
65 |
Correct |
2 ms |
376 KB |
Output is correct |
66 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |