Submission #93136

# Submission time Handle Problem Language Result Execution time Memory
93136 2019-01-06T15:05:34 Z Makhsud Chessboard (IZhO18_chessboard) C++17
8 / 100
70 ms 1080 KB
#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

chessboard.cpp: In function 'void subt_3_4_5()':
chessboard.cpp:21:7: warning: variable 'r' set but not used [-Wunused-but-set-variable]
    ll r, c;
       ^
chessboard.cpp:21:10: warning: variable 'c' set but not used [-Wunused-but-set-variable]
    ll r, c;
          ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 1080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 1080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 70 ms 1080 KB Output isn't correct
10 Halted 0 ms 0 KB -