Submission #92933

# Submission time Handle Problem Language Result Execution time Memory
92933 2019-01-06T07:05:38 Z Makhsud Chessboard (IZhO18_chessboard) C++17
0 / 100
2 ms 504 KB
#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

chessboard.cpp: In function 'int main()':
chessboard.cpp:22:8: warning: unused variable 'f1' [-Wunused-variable]
   bool f1 = true;
        ^~
chessboard.cpp:23:15: warning: unused variable 'mn' [-Wunused-variable]
   ll ans = 0, mn, ans1 = 0;
               ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -