답안 #378515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378515 2021-03-17T01:18:21 Z cheissmart Chessboard (IZhO18_chessboard) C++14
70 / 100
486 ms 4332 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;
const ll oo = 1e18;

signed main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	V<array<int, 4>> a(k);
	for(int i = 0; i < k; i++) {
		for(int j = 0; j < 4; j++)
			cin >> a[i][j], a[i][j]--;
	}

	ll ans = oo;
	auto go = [&] (int b) {
		assert(n % b == 0);
		int m = n / b;
		ll black = (ll) m * m / 2 * b * b, white = (ll) n * n - black;
		int black_type = 1;
		for(int _ = 0; _ < 2; _++) {
			int in_black = 0, in_white = 0;
			for(int i = 0; i < k; i++) {
				int tt = a[i][0] / b + a[i][1] / b;
				if(tt % 2 == black_type) in_black++;
				else in_white++;
			}
			assert(in_black <= black);
			assert(in_white <= white);
			ans = min(ans, in_white + black - in_black);
			swap(black, white);
			black_type ^= 1;
		}
	};

	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			go(i);
			if(n / i != i && n / i != n) go(n / i);
		}
	}
	cout << ans << '\n';

}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1260 KB Output is correct
2 Correct 7 ms 1004 KB Output is correct
3 Correct 17 ms 1900 KB Output is correct
4 Correct 18 ms 1900 KB Output is correct
5 Correct 24 ms 2540 KB Output is correct
6 Correct 16 ms 1644 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 15 ms 1772 KB Output is correct
9 Correct 39 ms 3820 KB Output is correct
10 Correct 21 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 12 ms 876 KB Output is correct
17 Correct 33 ms 1772 KB Output is correct
18 Correct 44 ms 2156 KB Output is correct
19 Correct 107 ms 1900 KB Output is correct
20 Correct 118 ms 2028 KB Output is correct
21 Correct 29 ms 1772 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 24 ms 1132 KB Output is correct
24 Correct 38 ms 1900 KB Output is correct
25 Correct 5 ms 620 KB Output is correct
26 Correct 25 ms 1388 KB Output is correct
27 Correct 33 ms 1516 KB Output is correct
28 Correct 40 ms 1900 KB Output is correct
29 Correct 12 ms 1024 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1260 KB Output is correct
2 Correct 7 ms 1004 KB Output is correct
3 Correct 17 ms 1900 KB Output is correct
4 Correct 18 ms 1900 KB Output is correct
5 Correct 24 ms 2540 KB Output is correct
6 Correct 16 ms 1644 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 15 ms 1772 KB Output is correct
9 Correct 39 ms 3820 KB Output is correct
10 Correct 21 ms 2284 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 380 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 12 ms 876 KB Output is correct
27 Correct 33 ms 1772 KB Output is correct
28 Correct 44 ms 2156 KB Output is correct
29 Correct 107 ms 1900 KB Output is correct
30 Correct 118 ms 2028 KB Output is correct
31 Correct 29 ms 1772 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 24 ms 1132 KB Output is correct
34 Correct 38 ms 1900 KB Output is correct
35 Correct 5 ms 620 KB Output is correct
36 Correct 25 ms 1388 KB Output is correct
37 Correct 33 ms 1516 KB Output is correct
38 Correct 40 ms 1900 KB Output is correct
39 Correct 12 ms 1024 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 98 ms 3564 KB Output is correct
42 Correct 49 ms 4076 KB Output is correct
43 Correct 64 ms 3692 KB Output is correct
44 Correct 44 ms 3948 KB Output is correct
45 Correct 41 ms 4204 KB Output is correct
46 Correct 111 ms 4076 KB Output is correct
47 Correct 35 ms 3692 KB Output is correct
48 Correct 55 ms 3820 KB Output is correct
49 Correct 42 ms 3692 KB Output is correct
50 Correct 442 ms 3948 KB Output is correct
51 Correct 466 ms 4204 KB Output is correct
52 Correct 450 ms 3948 KB Output is correct
53 Correct 466 ms 4204 KB Output is correct
54 Correct 432 ms 3948 KB Output is correct
55 Correct 486 ms 4332 KB Output is correct
56 Correct 421 ms 3692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 31 ms 1260 KB Output is correct
10 Correct 7 ms 1004 KB Output is correct
11 Correct 17 ms 1900 KB Output is correct
12 Correct 18 ms 1900 KB Output is correct
13 Correct 24 ms 2540 KB Output is correct
14 Correct 16 ms 1644 KB Output is correct
15 Correct 4 ms 620 KB Output is correct
16 Correct 15 ms 1772 KB Output is correct
17 Correct 39 ms 3820 KB Output is correct
18 Correct 21 ms 2284 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 380 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 12 ms 876 KB Output is correct
35 Correct 33 ms 1772 KB Output is correct
36 Correct 44 ms 2156 KB Output is correct
37 Correct 107 ms 1900 KB Output is correct
38 Correct 118 ms 2028 KB Output is correct
39 Correct 29 ms 1772 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 24 ms 1132 KB Output is correct
42 Correct 38 ms 1900 KB Output is correct
43 Correct 5 ms 620 KB Output is correct
44 Correct 25 ms 1388 KB Output is correct
45 Correct 33 ms 1516 KB Output is correct
46 Correct 40 ms 1900 KB Output is correct
47 Correct 12 ms 1024 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 98 ms 3564 KB Output is correct
50 Correct 49 ms 4076 KB Output is correct
51 Correct 64 ms 3692 KB Output is correct
52 Correct 44 ms 3948 KB Output is correct
53 Correct 41 ms 4204 KB Output is correct
54 Correct 111 ms 4076 KB Output is correct
55 Correct 35 ms 3692 KB Output is correct
56 Correct 55 ms 3820 KB Output is correct
57 Correct 42 ms 3692 KB Output is correct
58 Correct 442 ms 3948 KB Output is correct
59 Correct 466 ms 4204 KB Output is correct
60 Correct 450 ms 3948 KB Output is correct
61 Correct 466 ms 4204 KB Output is correct
62 Correct 432 ms 3948 KB Output is correct
63 Correct 486 ms 4332 KB Output is correct
64 Correct 421 ms 3692 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Incorrect 1 ms 364 KB Output isn't correct
67 Halted 0 ms 0 KB -