#include<bits/stdc++.h>
#define inf 1e18
#define int long long
#define N 1010
using namespace std;
int v[N][N];
int mark[N][N];
int32_t main(){
int n, k;
cin >> n >> k;
if(n > N-1 or n == 3){
int res1 = 0;
int res2 = 0;
int p = n;
if(n % 2 == 0){
res1 = 2;
res2 = 2;
}
else{
res1 = (p*p+1)/2;
res2 = (p*p-1)/2;
}
for(int i = 1;i <= k;i++){
int a, b, c, d;
cin >> a >> b >> c >> d;
if(a % 2 != b % 2){
res1++;
res2--;
}
else{
res1--;
res2++;
}
}
cout << min(res1, res2) << '\n';
return 0;
}
// vector <pair <int, int>> v;
for(int i = 1;i <= k;i++){
int a, b, c, d;
cin >> a >> b >> c >> d;
v[a][b] = 1;
}
int res = inf;
for(int p = 1;p < n;p++){
if(n % p != 0) continue;
int resp = 0;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
int ti = (i-1)/p;
int tj = (j-1)/p;
if((ti % 2 )!= (tj % 2)){
if(v[i][j] != 0) resp++;
}
else{
if(v[i][j] != 1) resp++;
}
}
}
// cout << p << ' ' << resp << '\n';
res = min(res, resp);
resp = 0;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
int ti = (i-1)/p;
int tj = (j-1)/p;
if((ti % 2 )!= (tj % 2)){
if(v[i][j] != 1) resp++;
}
else{
if(v[i][j] != 0) resp++;
}
}
}
res = min(res, resp);
}
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
348 KB |
Output is correct |
2 |
Correct |
12 ms |
604 KB |
Output is correct |
3 |
Correct |
30 ms |
1372 KB |
Output is correct |
4 |
Correct |
30 ms |
1108 KB |
Output is correct |
5 |
Correct |
42 ms |
1620 KB |
Output is correct |
6 |
Correct |
26 ms |
1116 KB |
Output is correct |
7 |
Correct |
8 ms |
452 KB |
Output is correct |
8 |
Correct |
26 ms |
1060 KB |
Output is correct |
9 |
Correct |
68 ms |
2500 KB |
Output is correct |
10 |
Correct |
39 ms |
1424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4540 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
2492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4540 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
2492 KB |
Output is correct |
16 |
Correct |
44 ms |
9564 KB |
Output is correct |
17 |
Correct |
70 ms |
9820 KB |
Output is correct |
18 |
Correct |
88 ms |
9936 KB |
Output is correct |
19 |
Correct |
291 ms |
9660 KB |
Output is correct |
20 |
Correct |
302 ms |
9660 KB |
Output is correct |
21 |
Correct |
59 ms |
9952 KB |
Output is correct |
22 |
Correct |
148 ms |
8796 KB |
Output is correct |
23 |
Correct |
89 ms |
9564 KB |
Output is correct |
24 |
Correct |
83 ms |
9936 KB |
Output is correct |
25 |
Correct |
72 ms |
9708 KB |
Output is correct |
26 |
Correct |
62 ms |
9564 KB |
Output is correct |
27 |
Correct |
87 ms |
9688 KB |
Output is correct |
28 |
Correct |
82 ms |
9564 KB |
Output is correct |
29 |
Correct |
30 ms |
9560 KB |
Output is correct |
30 |
Correct |
32 ms |
9304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
348 KB |
Output is correct |
2 |
Correct |
12 ms |
604 KB |
Output is correct |
3 |
Correct |
30 ms |
1372 KB |
Output is correct |
4 |
Correct |
30 ms |
1108 KB |
Output is correct |
5 |
Correct |
42 ms |
1620 KB |
Output is correct |
6 |
Correct |
26 ms |
1116 KB |
Output is correct |
7 |
Correct |
8 ms |
452 KB |
Output is correct |
8 |
Correct |
26 ms |
1060 KB |
Output is correct |
9 |
Correct |
68 ms |
2500 KB |
Output is correct |
10 |
Correct |
39 ms |
1424 KB |
Output is correct |
11 |
Correct |
1 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
2 ms |
4540 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
2 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
2492 KB |
Output is correct |
26 |
Correct |
44 ms |
9564 KB |
Output is correct |
27 |
Correct |
70 ms |
9820 KB |
Output is correct |
28 |
Correct |
88 ms |
9936 KB |
Output is correct |
29 |
Correct |
291 ms |
9660 KB |
Output is correct |
30 |
Correct |
302 ms |
9660 KB |
Output is correct |
31 |
Correct |
59 ms |
9952 KB |
Output is correct |
32 |
Correct |
148 ms |
8796 KB |
Output is correct |
33 |
Correct |
89 ms |
9564 KB |
Output is correct |
34 |
Correct |
83 ms |
9936 KB |
Output is correct |
35 |
Correct |
72 ms |
9708 KB |
Output is correct |
36 |
Correct |
62 ms |
9564 KB |
Output is correct |
37 |
Correct |
87 ms |
9688 KB |
Output is correct |
38 |
Correct |
82 ms |
9564 KB |
Output is correct |
39 |
Correct |
30 ms |
9560 KB |
Output is correct |
40 |
Correct |
32 ms |
9304 KB |
Output is correct |
41 |
Incorrect |
63 ms |
2196 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
46 ms |
348 KB |
Output is correct |
10 |
Correct |
12 ms |
604 KB |
Output is correct |
11 |
Correct |
30 ms |
1372 KB |
Output is correct |
12 |
Correct |
30 ms |
1108 KB |
Output is correct |
13 |
Correct |
42 ms |
1620 KB |
Output is correct |
14 |
Correct |
26 ms |
1116 KB |
Output is correct |
15 |
Correct |
8 ms |
452 KB |
Output is correct |
16 |
Correct |
26 ms |
1060 KB |
Output is correct |
17 |
Correct |
68 ms |
2500 KB |
Output is correct |
18 |
Correct |
39 ms |
1424 KB |
Output is correct |
19 |
Correct |
1 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
2 ms |
4540 KB |
Output is correct |
22 |
Correct |
2 ms |
4444 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
1 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
1 ms |
2492 KB |
Output is correct |
34 |
Correct |
44 ms |
9564 KB |
Output is correct |
35 |
Correct |
70 ms |
9820 KB |
Output is correct |
36 |
Correct |
88 ms |
9936 KB |
Output is correct |
37 |
Correct |
291 ms |
9660 KB |
Output is correct |
38 |
Correct |
302 ms |
9660 KB |
Output is correct |
39 |
Correct |
59 ms |
9952 KB |
Output is correct |
40 |
Correct |
148 ms |
8796 KB |
Output is correct |
41 |
Correct |
89 ms |
9564 KB |
Output is correct |
42 |
Correct |
83 ms |
9936 KB |
Output is correct |
43 |
Correct |
72 ms |
9708 KB |
Output is correct |
44 |
Correct |
62 ms |
9564 KB |
Output is correct |
45 |
Correct |
87 ms |
9688 KB |
Output is correct |
46 |
Correct |
82 ms |
9564 KB |
Output is correct |
47 |
Correct |
30 ms |
9560 KB |
Output is correct |
48 |
Correct |
32 ms |
9304 KB |
Output is correct |
49 |
Incorrect |
63 ms |
2196 KB |
Output isn't correct |
50 |
Halted |
0 ms |
0 KB |
- |