# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93136 | Makhsud | Chessboard (IZhO18_chessboard) | C++17 | 70 ms | 1080 KiB |
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 ll long long
using namespace std;
ll n, k, cnt, x, y, xx, yy;
ll a[3][3];
ll di[50005][5][5];
vector <ll> d;
void subt_3_4_5()
{
ll mn = INT_MAX, a1, a2;
for ( int i = 1; i < n; i ++ ){
if ( n % i == 0 ) {
d.push_back( i );
}
}
for ( int i = 1; i <= k; i ++ ){
cin >> x >> y >> xx >> yy;
for ( auto e: d ) {
ll r, c;
r = (x/e) + ( (x%e) && 1 );
c = (y/e) + ( (y%e) && 1 );
//di[e][r%2][c%2] ++;
}
}
for ( auto e: d ) {
a1 = a2 = 0;
for ( int i = 1; i <= (n/e); i ++ ) {
if ( i % 2 ) {
a1 += (e*e) * ((n/e)/2);
a2 += (e*e) * (((n/e)+1)/2);
}
else {
a2 += (e*e) * ((n/e)/2);
a1 += (e*e) * (((n/e)+1)/2);
}
}
a1 -= di[e][1][0] + di[e][0][1];
a1 += di[e][0][0] + di[e][1][1];
a2 += di[e][1][0] + di[e][0][1];
a2 -= di[e][0][0] + di[e][1][1];
mn = min ( mn, min ( a1, a2 ) );
}
cout << mn;
exit(0);
}
int main()
{
cin >> n >> k;
subt_3_4_5();
}
Compilation message (stderr)
# | 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... |