이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxK = 1e5;
struct rectangle {
int l1, c1, l2, c2;
};
rectangle black[maxK];
int main() {
int n, k;
long long cost, minCost;
cin >> n >> k;
for ( int i = 0; i < k; i++ )
cin >> black[i].l1 >> black[i].c1 >> black[i].l2 >> black[i].c2;
minCost = (long long)n * n;
for ( int l = 1; l < n; l++ ) {
if ( n % l == 0 ) {
int x = (n / l + 1) / 2, y = n / l / 2;
cost = ((long long)l * l) * ((long long)x * x + (long long)y * y);
for ( int i = 0; i < k; i++ ) {
int lin = (black[i].l1 - 1) / l;
int col = (black[i].c1 - 1) / l;
if ( (lin + col) % 2 == 0 )
cost--;
else
cost++;
}
minCost = min( minCost, cost );
cost = (long long)2 * x * y * l * l;
for ( int i = 0; i < k; i++ ) {
int lin = (black[i].l1 - 1) / l;
int col = (black[i].c1 - 1) / l;
if ( (lin + col) % 2 == 0 )
cost++;
else
cost--;
}
minCost = min( minCost, cost );
}
}
cout << minCost;
return 0;
}
# | 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... |