#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Size=1e5+1;
class point2d{
public:
ll x,y;
};
point2d top[Size],bot[Size];
pair<ll,ll> ans[Size];
void solve(){
ll n,k;
cin>>n>>k;
for(ll i=0;i<=n;i++){
ans[i].first=1e18;
ans[i].second=1e18;
}
for(ll i=0;i<k;i++){
cin>>top[i].y>>top[i].x>>bot[i].y>>bot[i].x;
top[i].y--;
top[i].x--;
bot[i].y--;
bot[i].x--;
}
for(ll i=n/2;i>=1;i--){
if(n%i==0){
if((n/i)%2==1){
ans[i].first=((n/i/2)*(n/i/2+1)*i*i)*2;
ans[i].second=ans[i].first+i*i;
}else{
ans[i].first=n*n/2;
ans[i].second=n*n/2;
}
}
}
ll best_ans=1e18;
for(ll i=1;i<=n/2;i++){
if(ans[i].first!=1e18){
for(ll j=0;j<k;j++){
if(((top[j].x/i)+(top[j].y/i))%2==1){
ans[i].first--;
ans[i].second++;
}else{
ans[i].first++;
ans[i].second--;
}
}
best_ans=min(best_ans,min(ans[i].first,ans[i].second));
}
}
cout<<best_ans<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t=1;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
4020 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
13 ms |
3780 KB |
Output is correct |
4 |
Correct |
15 ms |
2604 KB |
Output is correct |
5 |
Correct |
17 ms |
4108 KB |
Output is correct |
6 |
Correct |
11 ms |
2892 KB |
Output is correct |
7 |
Correct |
3 ms |
972 KB |
Output is correct |
8 |
Correct |
12 ms |
2964 KB |
Output is correct |
9 |
Correct |
36 ms |
5684 KB |
Output is correct |
10 |
Correct |
15 ms |
3660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
9 ms |
1612 KB |
Output is correct |
17 |
Correct |
21 ms |
4264 KB |
Output is correct |
18 |
Correct |
27 ms |
4976 KB |
Output is correct |
19 |
Correct |
56 ms |
4436 KB |
Output is correct |
20 |
Correct |
65 ms |
4996 KB |
Output is correct |
21 |
Correct |
23 ms |
4144 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
14 ms |
2364 KB |
Output is correct |
24 |
Correct |
25 ms |
4608 KB |
Output is correct |
25 |
Correct |
3 ms |
716 KB |
Output is correct |
26 |
Correct |
17 ms |
3024 KB |
Output is correct |
27 |
Correct |
21 ms |
3536 KB |
Output is correct |
28 |
Correct |
27 ms |
4816 KB |
Output is correct |
29 |
Correct |
9 ms |
1864 KB |
Output is correct |
30 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
4020 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
13 ms |
3780 KB |
Output is correct |
4 |
Correct |
15 ms |
2604 KB |
Output is correct |
5 |
Correct |
17 ms |
4108 KB |
Output is correct |
6 |
Correct |
11 ms |
2892 KB |
Output is correct |
7 |
Correct |
3 ms |
972 KB |
Output is correct |
8 |
Correct |
12 ms |
2964 KB |
Output is correct |
9 |
Correct |
36 ms |
5684 KB |
Output is correct |
10 |
Correct |
15 ms |
3660 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
9 ms |
1612 KB |
Output is correct |
27 |
Correct |
21 ms |
4264 KB |
Output is correct |
28 |
Correct |
27 ms |
4976 KB |
Output is correct |
29 |
Correct |
56 ms |
4436 KB |
Output is correct |
30 |
Correct |
65 ms |
4996 KB |
Output is correct |
31 |
Correct |
23 ms |
4144 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
14 ms |
2364 KB |
Output is correct |
34 |
Correct |
25 ms |
4608 KB |
Output is correct |
35 |
Correct |
3 ms |
716 KB |
Output is correct |
36 |
Correct |
17 ms |
3024 KB |
Output is correct |
37 |
Correct |
21 ms |
3536 KB |
Output is correct |
38 |
Correct |
27 ms |
4816 KB |
Output is correct |
39 |
Correct |
9 ms |
1864 KB |
Output is correct |
40 |
Correct |
1 ms |
460 KB |
Output is correct |
41 |
Correct |
60 ms |
6388 KB |
Output is correct |
42 |
Correct |
31 ms |
6952 KB |
Output is correct |
43 |
Correct |
39 ms |
6408 KB |
Output is correct |
44 |
Correct |
40 ms |
6864 KB |
Output is correct |
45 |
Correct |
30 ms |
7256 KB |
Output is correct |
46 |
Correct |
59 ms |
6988 KB |
Output is correct |
47 |
Correct |
26 ms |
6508 KB |
Output is correct |
48 |
Correct |
35 ms |
6596 KB |
Output is correct |
49 |
Correct |
28 ms |
6452 KB |
Output is correct |
50 |
Correct |
207 ms |
6724 KB |
Output is correct |
51 |
Correct |
217 ms |
6948 KB |
Output is correct |
52 |
Correct |
204 ms |
6572 KB |
Output is correct |
53 |
Correct |
216 ms |
7016 KB |
Output is correct |
54 |
Correct |
203 ms |
6468 KB |
Output is correct |
55 |
Correct |
224 ms |
6992 KB |
Output is correct |
56 |
Correct |
199 ms |
6368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 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 |
22 ms |
4020 KB |
Output is correct |
10 |
Correct |
5 ms |
1356 KB |
Output is correct |
11 |
Correct |
13 ms |
3780 KB |
Output is correct |
12 |
Correct |
15 ms |
2604 KB |
Output is correct |
13 |
Correct |
17 ms |
4108 KB |
Output is correct |
14 |
Correct |
11 ms |
2892 KB |
Output is correct |
15 |
Correct |
3 ms |
972 KB |
Output is correct |
16 |
Correct |
12 ms |
2964 KB |
Output is correct |
17 |
Correct |
36 ms |
5684 KB |
Output is correct |
18 |
Correct |
15 ms |
3660 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
0 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
328 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
9 ms |
1612 KB |
Output is correct |
35 |
Correct |
21 ms |
4264 KB |
Output is correct |
36 |
Correct |
27 ms |
4976 KB |
Output is correct |
37 |
Correct |
56 ms |
4436 KB |
Output is correct |
38 |
Correct |
65 ms |
4996 KB |
Output is correct |
39 |
Correct |
23 ms |
4144 KB |
Output is correct |
40 |
Correct |
1 ms |
332 KB |
Output is correct |
41 |
Correct |
14 ms |
2364 KB |
Output is correct |
42 |
Correct |
25 ms |
4608 KB |
Output is correct |
43 |
Correct |
3 ms |
716 KB |
Output is correct |
44 |
Correct |
17 ms |
3024 KB |
Output is correct |
45 |
Correct |
21 ms |
3536 KB |
Output is correct |
46 |
Correct |
27 ms |
4816 KB |
Output is correct |
47 |
Correct |
9 ms |
1864 KB |
Output is correct |
48 |
Correct |
1 ms |
460 KB |
Output is correct |
49 |
Correct |
60 ms |
6388 KB |
Output is correct |
50 |
Correct |
31 ms |
6952 KB |
Output is correct |
51 |
Correct |
39 ms |
6408 KB |
Output is correct |
52 |
Correct |
40 ms |
6864 KB |
Output is correct |
53 |
Correct |
30 ms |
7256 KB |
Output is correct |
54 |
Correct |
59 ms |
6988 KB |
Output is correct |
55 |
Correct |
26 ms |
6508 KB |
Output is correct |
56 |
Correct |
35 ms |
6596 KB |
Output is correct |
57 |
Correct |
28 ms |
6452 KB |
Output is correct |
58 |
Correct |
207 ms |
6724 KB |
Output is correct |
59 |
Correct |
217 ms |
6948 KB |
Output is correct |
60 |
Correct |
204 ms |
6572 KB |
Output is correct |
61 |
Correct |
216 ms |
7016 KB |
Output is correct |
62 |
Correct |
203 ms |
6468 KB |
Output is correct |
63 |
Correct |
224 ms |
6992 KB |
Output is correct |
64 |
Correct |
199 ms |
6368 KB |
Output is correct |
65 |
Correct |
0 ms |
332 KB |
Output is correct |
66 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |