This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++;
}
}
}
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++;
}
}
}
}
cout << res << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |