답안 #555240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
555240 2022-04-30T10:05:47 Z ngpin04 Chessboard (IZhO18_chessboard) C++14
70 / 100
334 ms 6612 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define TASK ""
#define ALL(x) (x).begin(), (x).end() 
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}
const int N = 1e5 + 5; 
const int oo = 1e9;
const long long ooo = 1e18;
const int mod = 1e9 + 7; // 998244353;
const long double pi = acos(-1);

vector <int> p[N];

int x[N];
int y[N];
int u[N];
int v[N];
int n,k;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef ONLINE_JUDGE
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	#endif
	cin >> n >> k;
	if (n <= 100 && k == 0) {
		int ans = oo;
		for (int i = 1; i < n; i++) if (n % i == 0) {
			int d = (n / i);
			mini(ans, ((d * d) >> 1) * i * i);
			// cerr << d << " " << i << "\n";
		}
		cout << ans << "\n";
		return 0;
	}

	for (int i = 1; i <= k; i++)
		cin >> x[i] >> y[i] >> u[i] >> v[i];

	long long ans = ooo;
	for (int i = 1; i < n; i++) if (n % i == 0) 
	for (int v = 0; v < 2; v++) {
		int d = (n / i);
		long long res = ((1LL * d * d + v) >> 1) * i * i;
		// cerr << "split: " << i << " " << v << " " << res << "\n";
		for (int j = 1; j <= k; j++) {
			int c = ( ((x[j] - 1) / i + (y[j] - 1) / i) & 1) ^ v;
			// cerr << (x[j] - 1) << " " << (y[j] - 1) << " " << c << "\n";
			res += (c > 0) ? -1 : 1;
		}
		mini(ans, res);
	}

	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 5036 KB Output is correct
2 Correct 7 ms 3284 KB Output is correct
3 Correct 16 ms 4184 KB Output is correct
4 Correct 17 ms 4244 KB Output is correct
5 Correct 20 ms 4776 KB Output is correct
6 Correct 18 ms 4032 KB Output is correct
7 Correct 4 ms 2900 KB Output is correct
8 Correct 16 ms 4052 KB Output is correct
9 Correct 33 ms 6092 KB Output is correct
10 Correct 18 ms 4532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2672 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2684 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2672 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2684 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 10 ms 3540 KB Output is correct
17 Correct 26 ms 5248 KB Output is correct
18 Correct 33 ms 5792 KB Output is correct
19 Correct 77 ms 5568 KB Output is correct
20 Correct 81 ms 5696 KB Output is correct
21 Correct 22 ms 5164 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 18 ms 3924 KB Output is correct
24 Correct 29 ms 5412 KB Output is correct
25 Correct 5 ms 2924 KB Output is correct
26 Correct 26 ms 4380 KB Output is correct
27 Correct 27 ms 4928 KB Output is correct
28 Correct 31 ms 5676 KB Output is correct
29 Correct 10 ms 3708 KB Output is correct
30 Correct 3 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 5036 KB Output is correct
2 Correct 7 ms 3284 KB Output is correct
3 Correct 16 ms 4184 KB Output is correct
4 Correct 17 ms 4244 KB Output is correct
5 Correct 20 ms 4776 KB Output is correct
6 Correct 18 ms 4032 KB Output is correct
7 Correct 4 ms 2900 KB Output is correct
8 Correct 16 ms 4052 KB Output is correct
9 Correct 33 ms 6092 KB Output is correct
10 Correct 18 ms 4532 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2672 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 3 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2684 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 10 ms 3540 KB Output is correct
27 Correct 26 ms 5248 KB Output is correct
28 Correct 33 ms 5792 KB Output is correct
29 Correct 77 ms 5568 KB Output is correct
30 Correct 81 ms 5696 KB Output is correct
31 Correct 22 ms 5164 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 18 ms 3924 KB Output is correct
34 Correct 29 ms 5412 KB Output is correct
35 Correct 5 ms 2924 KB Output is correct
36 Correct 26 ms 4380 KB Output is correct
37 Correct 27 ms 4928 KB Output is correct
38 Correct 31 ms 5676 KB Output is correct
39 Correct 10 ms 3708 KB Output is correct
40 Correct 3 ms 2688 KB Output is correct
41 Correct 72 ms 5904 KB Output is correct
42 Correct 37 ms 6304 KB Output is correct
43 Correct 49 ms 5940 KB Output is correct
44 Correct 37 ms 6252 KB Output is correct
45 Correct 36 ms 6516 KB Output is correct
46 Correct 82 ms 6348 KB Output is correct
47 Correct 31 ms 5960 KB Output is correct
48 Correct 43 ms 6012 KB Output is correct
49 Correct 33 ms 5952 KB Output is correct
50 Correct 298 ms 6144 KB Output is correct
51 Correct 311 ms 6496 KB Output is correct
52 Correct 289 ms 6132 KB Output is correct
53 Correct 312 ms 6348 KB Output is correct
54 Correct 289 ms 6092 KB Output is correct
55 Correct 334 ms 6612 KB Output is correct
56 Correct 280 ms 6020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 25 ms 5036 KB Output is correct
10 Correct 7 ms 3284 KB Output is correct
11 Correct 16 ms 4184 KB Output is correct
12 Correct 17 ms 4244 KB Output is correct
13 Correct 20 ms 4776 KB Output is correct
14 Correct 18 ms 4032 KB Output is correct
15 Correct 4 ms 2900 KB Output is correct
16 Correct 16 ms 4052 KB Output is correct
17 Correct 33 ms 6092 KB Output is correct
18 Correct 18 ms 4532 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2672 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 3 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2684 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 10 ms 3540 KB Output is correct
35 Correct 26 ms 5248 KB Output is correct
36 Correct 33 ms 5792 KB Output is correct
37 Correct 77 ms 5568 KB Output is correct
38 Correct 81 ms 5696 KB Output is correct
39 Correct 22 ms 5164 KB Output is correct
40 Correct 2 ms 2644 KB Output is correct
41 Correct 18 ms 3924 KB Output is correct
42 Correct 29 ms 5412 KB Output is correct
43 Correct 5 ms 2924 KB Output is correct
44 Correct 26 ms 4380 KB Output is correct
45 Correct 27 ms 4928 KB Output is correct
46 Correct 31 ms 5676 KB Output is correct
47 Correct 10 ms 3708 KB Output is correct
48 Correct 3 ms 2688 KB Output is correct
49 Correct 72 ms 5904 KB Output is correct
50 Correct 37 ms 6304 KB Output is correct
51 Correct 49 ms 5940 KB Output is correct
52 Correct 37 ms 6252 KB Output is correct
53 Correct 36 ms 6516 KB Output is correct
54 Correct 82 ms 6348 KB Output is correct
55 Correct 31 ms 5960 KB Output is correct
56 Correct 43 ms 6012 KB Output is correct
57 Correct 33 ms 5952 KB Output is correct
58 Correct 298 ms 6144 KB Output is correct
59 Correct 311 ms 6496 KB Output is correct
60 Correct 289 ms 6132 KB Output is correct
61 Correct 312 ms 6348 KB Output is correct
62 Correct 289 ms 6092 KB Output is correct
63 Correct 334 ms 6612 KB Output is correct
64 Correct 280 ms 6020 KB Output is correct
65 Correct 2 ms 2644 KB Output is correct
66 Incorrect 2 ms 2680 KB Output isn't correct
67 Halted 0 ms 0 KB -