답안 #93117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93117 2019-01-06T14:17:33 Z Makhsud Chessboard (IZhO18_chessboard) C++17
47 / 100
141 ms 2396 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];
void subt1()
{
	ll mn = INT_MAX;
	for ( int i = 1; i < n; i ++ ){
		if ( n % i == 0 ) {
			ll c = 0;
			for ( int j = 1; j <= (n/i); j ++ ) {
				if ( j % 2 ) {
					c += (i*i) * ( ( n/i ) / 2 );
				}
				else {
					c += (i*i) * ( ( ( n/i ) + 1 ) / 2 );
				}
			}
			mn = min( mn, c );
		}
	}
	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);
}
void subt3()
{
	ll mn = INT_MAX, a1, a2;
	vector <ll> d(0);
	for ( int i = 1; i < n; i ++ ){
		if ( n % i == 0 ) {
			d.push_back( (ll) 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;
	for ( int i = 1; i <= n; i ++ ) {
		if ( n % i == 0 ) cnt ++;
	}
	if ( cnt == 2 ) subt2();
	if ( k > 0 ) subt3();
	subt1();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 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 248 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 376 KB Output is correct
2 Correct 19 ms 376 KB Output is correct
3 Correct 46 ms 364 KB Output is correct
4 Correct 48 ms 476 KB Output is correct
5 Correct 64 ms 256 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 99 ms 376 KB Output is correct
10 Correct 56 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 256 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 256 KB Output is correct
8 Correct 2 ms 252 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 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 256 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 256 KB Output is correct
8 Correct 2 ms 252 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 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 26 ms 760 KB Output is correct
17 Correct 70 ms 1656 KB Output is correct
18 Correct 89 ms 1912 KB Output is correct
19 Correct 126 ms 1784 KB Output is correct
20 Correct 141 ms 1912 KB Output is correct
21 Correct 68 ms 1528 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 44 ms 888 KB Output is correct
24 Correct 82 ms 1728 KB Output is correct
25 Correct 10 ms 376 KB Output is correct
26 Correct 52 ms 1144 KB Output is correct
27 Correct 65 ms 1404 KB Output is correct
28 Correct 87 ms 1848 KB Output is correct
29 Correct 29 ms 788 KB Output is correct
30 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 376 KB Output is correct
2 Correct 19 ms 376 KB Output is correct
3 Correct 46 ms 364 KB Output is correct
4 Correct 48 ms 476 KB Output is correct
5 Correct 64 ms 256 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 99 ms 376 KB Output is correct
10 Correct 56 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 252 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 256 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 26 ms 760 KB Output is correct
27 Correct 70 ms 1656 KB Output is correct
28 Correct 89 ms 1912 KB Output is correct
29 Correct 126 ms 1784 KB Output is correct
30 Correct 141 ms 1912 KB Output is correct
31 Correct 68 ms 1528 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 44 ms 888 KB Output is correct
34 Correct 82 ms 1728 KB Output is correct
35 Correct 10 ms 376 KB Output is correct
36 Correct 52 ms 1144 KB Output is correct
37 Correct 65 ms 1404 KB Output is correct
38 Correct 87 ms 1848 KB Output is correct
39 Correct 29 ms 788 KB Output is correct
40 Correct 4 ms 256 KB Output is correct
41 Incorrect 139 ms 2396 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 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 248 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 71 ms 376 KB Output is correct
10 Correct 19 ms 376 KB Output is correct
11 Correct 46 ms 364 KB Output is correct
12 Correct 48 ms 476 KB Output is correct
13 Correct 64 ms 256 KB Output is correct
14 Correct 46 ms 376 KB Output is correct
15 Correct 10 ms 376 KB Output is correct
16 Correct 42 ms 376 KB Output is correct
17 Correct 99 ms 376 KB Output is correct
18 Correct 56 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 252 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 256 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 26 ms 760 KB Output is correct
35 Correct 70 ms 1656 KB Output is correct
36 Correct 89 ms 1912 KB Output is correct
37 Correct 126 ms 1784 KB Output is correct
38 Correct 141 ms 1912 KB Output is correct
39 Correct 68 ms 1528 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 44 ms 888 KB Output is correct
42 Correct 82 ms 1728 KB Output is correct
43 Correct 10 ms 376 KB Output is correct
44 Correct 52 ms 1144 KB Output is correct
45 Correct 65 ms 1404 KB Output is correct
46 Correct 87 ms 1848 KB Output is correct
47 Correct 29 ms 788 KB Output is correct
48 Correct 4 ms 256 KB Output is correct
49 Incorrect 139 ms 2396 KB Output isn't correct
50 Halted 0 ms 0 KB -