Submission #93162

# Submission time Handle Problem Language Result Execution time Memory
93162 2019-01-06T16:18:32 Z Makhsud Chessboard (IZhO18_chessboard) C++17
39 / 100
143 ms 1912 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n, k, cnt, x, y, xx, yy;
ll a[50005][3][3];
vector <ll> d;

int main()
{
	cin >> n >> k;
	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;
		ll r, c;
		for ( auto e: d ) {
			r = (x/e) + ( (x%e) && 1 );
			c = (y/e) + ( (y%e) && 1 );
			a[e][r%2][c%2] ++;
		}
	}
	ll ans1, ans2, mn = INT_MAX;
	for ( auto e: d ) {
		ans1 = ans2 = 0;
		for ( int i = 1; i <= (n/e); i ++ ) {
			if ( i % 2 == 1 ) {
				ans1 += (e*e) * ( (n/e) / 2 );
				ans2 += (e*e) * ( ( (n/e) + 1 ) / 2 );
			} else {
				ans1 += (e*e) * ( ( (n/e) + 1 ) / 2 );
				ans2 += (e*e) * ( (n/e) / 2 );
			}
		}
		if ( k != n*n ){
			ans1 = ans1 + a[e][1][1] + a[e][0][0];
			ans2 = ans2 + a[e][1][0] + a[e][0][1];
			ans1 = ans1 - ( a[e][1][0] + a[e][0][1] );
			ans2 = ans2 - ( a[e][1][1] + a[e][0][0] );
		}
		mn = min ( mn, min ( ans1, ans2 ) );
	}
	cout << mn;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 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 Correct 76 ms 504 KB Output is correct
2 Correct 20 ms 632 KB Output is correct
3 Incorrect 48 ms 1148 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 252 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 252 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 26 ms 632 KB Output is correct
17 Correct 73 ms 1656 KB Output is correct
18 Correct 90 ms 1912 KB Output is correct
19 Correct 126 ms 1656 KB Output is correct
20 Correct 143 ms 1912 KB Output is correct
21 Correct 72 ms 1604 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 44 ms 1016 KB Output is correct
24 Correct 83 ms 1656 KB Output is correct
25 Correct 10 ms 376 KB Output is correct
26 Correct 53 ms 1144 KB Output is correct
27 Correct 66 ms 1400 KB Output is correct
28 Correct 93 ms 1784 KB Output is correct
29 Correct 32 ms 760 KB Output is correct
30 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 504 KB Output is correct
2 Correct 20 ms 632 KB Output is correct
3 Incorrect 48 ms 1148 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 76 ms 504 KB Output is correct
10 Correct 20 ms 632 KB Output is correct
11 Incorrect 48 ms 1148 KB Output isn't correct
12 Halted 0 ms 0 KB -