#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;
// 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';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
604 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4544 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 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 |
4548 KB |
Output is correct |
12 |
Correct |
1 ms |
4548 KB |
Output is correct |
13 |
Correct |
1 ms |
4548 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4544 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 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 |
4548 KB |
Output is correct |
12 |
Correct |
1 ms |
4548 KB |
Output is correct |
13 |
Correct |
1 ms |
4548 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
45 ms |
9816 KB |
Output is correct |
17 |
Correct |
62 ms |
11232 KB |
Output is correct |
18 |
Correct |
88 ms |
11344 KB |
Output is correct |
19 |
Correct |
295 ms |
11096 KB |
Output is correct |
20 |
Correct |
313 ms |
11268 KB |
Output is correct |
21 |
Correct |
58 ms |
11100 KB |
Output is correct |
22 |
Correct |
147 ms |
8908 KB |
Output is correct |
23 |
Correct |
90 ms |
10328 KB |
Output is correct |
24 |
Correct |
86 ms |
11300 KB |
Output is correct |
25 |
Correct |
71 ms |
9820 KB |
Output is correct |
26 |
Correct |
66 ms |
10504 KB |
Output is correct |
27 |
Correct |
93 ms |
10844 KB |
Output is correct |
28 |
Correct |
90 ms |
11092 KB |
Output is correct |
29 |
Correct |
32 ms |
10076 KB |
Output is correct |
30 |
Correct |
32 ms |
9560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
604 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |