Submission #93114

# Submission time Handle Problem Language Result Execution time Memory
93114 2019-01-06T13:56:02 Z Makhsud Chessboard (IZhO18_chessboard) C++17
8 / 100
100 ms 376 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n, k, cnt, x, y, xx, yy;
ll a[3][3];
void subt1()
{
	ll mn = INT_MAX;
	for ( int i = 1; i < n; i ++ ){
		if ( n % i == 0 ) {
			ll c1 = 0, c2;
			for ( int j = 1; j <= n; j += i ) {
				if ( j % 2 ) {
					c1 += (i*i) * ( ( n/i ) / 2 );
					c2 += (i*i) * ( ( ( n/i ) + 1 ) / 2 );
				}
				else {
					c2 += (i*i) * ( ( n/i ) / 2 );
					c1 += (i*i) * ( ( ( n/i ) + 1 ) / 2 );
				}
			}
			mn = min( mn, min( c1, c2 ) );
		}
	}
	cout << mn;
	exit(0);
}
void subt2()
{
	ll c1, c2;
	c1 = c2 = 0;
	for ( int i = 1; i <= k; i ++ ) {
		cin >> x >> y >> xx >> yy;
		a[x%2][y%2] ++;
	}
	c1 = (n*n)/2;
	c2 =  c1 + 1;

	c1 = c1 - ( a[1][0] + a[0][1] );
	c1 = c1 + ( a[1][1] + a[0][0] );

	c2 = c2 - ( a[1][1] + a[0][0] );
	c2 = c2 + ( a[1][0] + a[0][1] );

	cout << min( c1, c2 );
	exit(0);
}

int main()
{
	cin >> n >> k;
	for ( int i = 1; i <= n; i ++ ) {
		if ( n % i == 0 ) cnt ++;
	}
	if ( cnt == 2 ) subt2();
	subt1();
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 376 KB Output is correct
2 Correct 19 ms 376 KB Output is correct
3 Correct 47 ms 296 KB Output is correct
4 Correct 44 ms 360 KB Output is correct
5 Correct 63 ms 376 KB Output is correct
6 Correct 46 ms 376 KB Output is correct
7 Correct 10 ms 376 KB Output is correct
8 Correct 42 ms 376 KB Output is correct
9 Correct 100 ms 376 KB Output is correct
10 Correct 57 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 376 KB Output is correct
2 Correct 19 ms 376 KB Output is correct
3 Correct 47 ms 296 KB Output is correct
4 Correct 44 ms 360 KB Output is correct
5 Correct 63 ms 376 KB Output is correct
6 Correct 46 ms 376 KB Output is correct
7 Correct 10 ms 376 KB Output is correct
8 Correct 42 ms 376 KB Output is correct
9 Correct 100 ms 376 KB Output is correct
10 Correct 57 ms 376 KB Output is correct
11 Incorrect 2 ms 256 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -