# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92933 | Makhsud | Chessboard (IZhO18_chessboard) | C++17 | 2 ms | 504 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
ll n, k, x, y, xx, yy;
ll d;
bool used[150][150], pr = false;
using namespace std;
int main()
{
cin >> n >> k;
for ( int i = 1; i <= k; i ++ ) {
cin >> x >> y >> xx >> yy;
used[x][y] = true;
}
ll cn = 0;
for ( int i = 1; i <= n; i ++ ) {
if ( n % i == 0 ) cn ++;
}
if ( cn == 2 ) {
bool f1 = true;
ll ans = 0, mn, ans1 = 0;
for ( int i = 1; i <= n; i ++ ) {
for ( int j = 1; j <= n; j ++ ) {
if ( i % 2 == 1 ) {
if ( j % 2 == 1 ) {
if ( !used[i][j] ) ans ++;
}
else {
if ( used[i][j] ) ans ++;
}
}
if ( i % 2 == 0 ) {
if ( j % 2 == 0 ) {
if ( !used[i][j] ) ans ++;
}
else {
if ( used[i][j] ) ans ++;
}
}
}
}
for ( int i = 1; i <= n; i ++ ) {
for ( int j = 1; j <= n; j ++ ) {
if ( i % 2 == 1 ) {
if ( j % 2 == 0 ) {
if ( !used[i][j] ) ans1 ++;
}
else {
if ( used[i][j] ) ans1 ++;
}
}
if ( i % 2 == 0 ) {
if ( j % 2 == 1 ) {
if ( !used[i][j] ) ans1 ++;
}
else {
if ( used[i][j] ) ans1 ++;
}
}
}
}
cout << min ( ans, ans1 );
return 0;
}
for ( int i = n-1; i >= 1; i -- ) {
if ( n % i == 0 ) {
d = i;
break;
}
}
if ( d == 1 ) {
cout << (n*n) / 2;
}
else {
ll cnt = 0;
bool ch = false;
for ( int i = 1; i <= n; i += d ) {
ch = !ch;
if ( ch ) {
cnt += ( n / d ) / 2;
}
else {
cnt += ( n / d + 1 ) / 2;
}
}
cout << cnt * (d*d);
}
}
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... |