#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
ll n,k,p,u,ans,i,j,v,x[100005],y[100005],ans1,ans2,t,q;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
for(i=1;i<=k;i++)
{
cin>>x[i]>>y[i]>>x[i]>>y[i];
if(x[i]%2==y[i]%2)
u++;
else
v++;
}
if(n%2==0)
p=n*n/2;
else
p=n*n/2+1;
q=n*n/2;
ans=min(p-u+v,q-v+u);
for(j=2;j<=n;j++)
{
if(n%j==0)
{
u=0;
v=0;
t=n/j;
for(i=1;i<=k;i++)
{
ll g,h;
if(x[i]%t==0)
g=x[i]/t;
else
g=x[i]/t+1;
if(y[i]%t==0)
h=y[i]/t;
else
h=y[i]/t+1;
if(h%2==g%2)
u++;
else
v++;
}
q=n/j;
if(j%2==1)
ans1=j*j/2+1;
else
ans1=j*j/2;
ans1=ans1*q*q;
ans1=ans1-u+v;
ans2=j*j/2;
ans2=ans2*q*q;
ans2=ans2-v+u;
ans=min(ans,ans2);
ans=min(ans,ans1);
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1376 KB |
Output is correct |
2 |
Correct |
9 ms |
632 KB |
Output is correct |
3 |
Correct |
21 ms |
1016 KB |
Output is correct |
4 |
Correct |
22 ms |
1016 KB |
Output is correct |
5 |
Correct |
28 ms |
1400 KB |
Output is correct |
6 |
Correct |
19 ms |
888 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
888 KB |
Output is correct |
9 |
Correct |
45 ms |
1912 KB |
Output is correct |
10 |
Correct |
26 ms |
1144 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 |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 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 |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 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 |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 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 |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 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 |
15 ms |
760 KB |
Output is correct |
17 |
Correct |
34 ms |
1628 KB |
Output is correct |
18 |
Correct |
47 ms |
1972 KB |
Output is correct |
19 |
Correct |
116 ms |
1768 KB |
Output is correct |
20 |
Correct |
129 ms |
1912 KB |
Output is correct |
21 |
Correct |
33 ms |
1656 KB |
Output is correct |
22 |
Correct |
2 ms |
380 KB |
Output is correct |
23 |
Correct |
27 ms |
1016 KB |
Output is correct |
24 |
Correct |
43 ms |
1784 KB |
Output is correct |
25 |
Correct |
7 ms |
504 KB |
Output is correct |
26 |
Correct |
27 ms |
1144 KB |
Output is correct |
27 |
Correct |
38 ms |
1400 KB |
Output is correct |
28 |
Correct |
45 ms |
2028 KB |
Output is correct |
29 |
Correct |
15 ms |
888 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1376 KB |
Output is correct |
2 |
Correct |
9 ms |
632 KB |
Output is correct |
3 |
Correct |
21 ms |
1016 KB |
Output is correct |
4 |
Correct |
22 ms |
1016 KB |
Output is correct |
5 |
Correct |
28 ms |
1400 KB |
Output is correct |
6 |
Correct |
19 ms |
888 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
888 KB |
Output is correct |
9 |
Correct |
45 ms |
1912 KB |
Output is correct |
10 |
Correct |
26 ms |
1144 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 |
3 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 |
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 |
0 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 |
15 ms |
760 KB |
Output is correct |
27 |
Correct |
34 ms |
1628 KB |
Output is correct |
28 |
Correct |
47 ms |
1972 KB |
Output is correct |
29 |
Correct |
116 ms |
1768 KB |
Output is correct |
30 |
Correct |
129 ms |
1912 KB |
Output is correct |
31 |
Correct |
33 ms |
1656 KB |
Output is correct |
32 |
Correct |
2 ms |
380 KB |
Output is correct |
33 |
Correct |
27 ms |
1016 KB |
Output is correct |
34 |
Correct |
43 ms |
1784 KB |
Output is correct |
35 |
Correct |
7 ms |
504 KB |
Output is correct |
36 |
Correct |
27 ms |
1144 KB |
Output is correct |
37 |
Correct |
38 ms |
1400 KB |
Output is correct |
38 |
Correct |
45 ms |
2028 KB |
Output is correct |
39 |
Correct |
15 ms |
888 KB |
Output is correct |
40 |
Correct |
3 ms |
376 KB |
Output is correct |
41 |
Correct |
108 ms |
1688 KB |
Output is correct |
42 |
Correct |
53 ms |
1784 KB |
Output is correct |
43 |
Correct |
70 ms |
1736 KB |
Output is correct |
44 |
Correct |
52 ms |
1756 KB |
Output is correct |
45 |
Correct |
48 ms |
1912 KB |
Output is correct |
46 |
Correct |
117 ms |
1784 KB |
Output is correct |
47 |
Correct |
43 ms |
1656 KB |
Output is correct |
48 |
Correct |
61 ms |
1656 KB |
Output is correct |
49 |
Correct |
47 ms |
1656 KB |
Output is correct |
50 |
Correct |
444 ms |
1912 KB |
Output is correct |
51 |
Correct |
475 ms |
1896 KB |
Output is correct |
52 |
Correct |
445 ms |
1912 KB |
Output is correct |
53 |
Correct |
476 ms |
1912 KB |
Output is correct |
54 |
Correct |
436 ms |
1656 KB |
Output is correct |
55 |
Correct |
491 ms |
1980 KB |
Output is correct |
56 |
Correct |
422 ms |
1732 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 |
2 ms |
380 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 |
504 KB |
Output is correct |
9 |
Correct |
32 ms |
1376 KB |
Output is correct |
10 |
Correct |
9 ms |
632 KB |
Output is correct |
11 |
Correct |
21 ms |
1016 KB |
Output is correct |
12 |
Correct |
22 ms |
1016 KB |
Output is correct |
13 |
Correct |
28 ms |
1400 KB |
Output is correct |
14 |
Correct |
19 ms |
888 KB |
Output is correct |
15 |
Correct |
6 ms |
504 KB |
Output is correct |
16 |
Correct |
19 ms |
888 KB |
Output is correct |
17 |
Correct |
45 ms |
1912 KB |
Output is correct |
18 |
Correct |
26 ms |
1144 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 |
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 |
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 |
0 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 |
15 ms |
760 KB |
Output is correct |
35 |
Correct |
34 ms |
1628 KB |
Output is correct |
36 |
Correct |
47 ms |
1972 KB |
Output is correct |
37 |
Correct |
116 ms |
1768 KB |
Output is correct |
38 |
Correct |
129 ms |
1912 KB |
Output is correct |
39 |
Correct |
33 ms |
1656 KB |
Output is correct |
40 |
Correct |
2 ms |
380 KB |
Output is correct |
41 |
Correct |
27 ms |
1016 KB |
Output is correct |
42 |
Correct |
43 ms |
1784 KB |
Output is correct |
43 |
Correct |
7 ms |
504 KB |
Output is correct |
44 |
Correct |
27 ms |
1144 KB |
Output is correct |
45 |
Correct |
38 ms |
1400 KB |
Output is correct |
46 |
Correct |
45 ms |
2028 KB |
Output is correct |
47 |
Correct |
15 ms |
888 KB |
Output is correct |
48 |
Correct |
3 ms |
376 KB |
Output is correct |
49 |
Correct |
108 ms |
1688 KB |
Output is correct |
50 |
Correct |
53 ms |
1784 KB |
Output is correct |
51 |
Correct |
70 ms |
1736 KB |
Output is correct |
52 |
Correct |
52 ms |
1756 KB |
Output is correct |
53 |
Correct |
48 ms |
1912 KB |
Output is correct |
54 |
Correct |
117 ms |
1784 KB |
Output is correct |
55 |
Correct |
43 ms |
1656 KB |
Output is correct |
56 |
Correct |
61 ms |
1656 KB |
Output is correct |
57 |
Correct |
47 ms |
1656 KB |
Output is correct |
58 |
Correct |
444 ms |
1912 KB |
Output is correct |
59 |
Correct |
475 ms |
1896 KB |
Output is correct |
60 |
Correct |
445 ms |
1912 KB |
Output is correct |
61 |
Correct |
476 ms |
1912 KB |
Output is correct |
62 |
Correct |
436 ms |
1656 KB |
Output is correct |
63 |
Correct |
491 ms |
1980 KB |
Output is correct |
64 |
Correct |
422 ms |
1732 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 |
- |