# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
892997 | 2023-12-26T09:49:44 Z | vjudge1 | Chessboard (IZhO18_chessboard) | C++17 | 48 ms | 6996 KB |
// 以上帝的名义 // 候选硕士 #include <bits/stdc++.h> #ifdef local #include "algo/debug.h" #else #define dbg(x...) 0 #endif using namespace std ; using ll = long long ; bool isPrime(int x) { if (x < 2) return 0 ; for (int i = 2 ; i * i <= x ; i++) { if (x % i == 0) { return 0 ; } } return 1 ; } int32_t main() { cin.tie(0)->sync_with_stdio(false) ; ll n, k ; cin >> n >> k ; struct rect { int x1, y1, x2, y2; void read() { cin >> x1 >> y1 >> x2 >> y2 ; x1--, y1-- , x2-- , y2-- ; } }; vector<rect> a(k) ; for (int i = 0 ; i < k ; i++) a[i].read() ; vector<int> d; for (int i = 1 ; i * i <= n ; i++) { if (n % i) continue ; d.push_back(i) ; if (n / i != i) d.push_back(n / i) ; } auto calc = [&](ll del) -> ll{ vector<vector<ll>> cnt(del + 1, vector<ll>(2, 0)) ; int block = n / del ; for (int i = 0 ; i < k ; i++) { int x1 = a[i].x1 , y1 = a[i].y1 , x2 = a[i].x2, y2 = a[i].y2 ; cnt[x1 / block][(y1 / block) % 2]++; } dbg(cnt) ; ll ret = 0 , sum = 0 ; for (int i = 0 ; i < del ; i++) { // for (int j = 0 ; j < del ; j++) { if (i % 2 == 0) { ll c = ((del + 1) / 2) * (block * block) ; ll cur = c - cnt[i][0] + cnt[i][1] ; sum += cur ; } else { ll c = (del / 2) * (block * block) ; ll cur = c - cnt[i][1] + cnt[i][0] ; sum += cur ; } // } } ret = sum ; sum = 0 ; for (int i = 0 ; i < del ; i++) { // for (int j = 0 ; j < del ; j++) { if (i % 2 != 0) { ll c = ((del + 1) / 2) * (block * block) ; ll cur = c - cnt[i][0] + cnt[i][1] ; sum += cur ; } else { ll c = (del / 2) * (block * block) ; ll cur = c - cnt[i][1] + cnt[i][0] ; sum += cur ; } // } } ret = min(ret, sum) ; return ret ; }; ll ret = LLONG_MAX ; for (int i : d) { dbg(i, calc(i)) ; if (i > 1) ret = min(ret, calc(i)) ; } cout << ret ; return 0 ; } // 希望白银
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 4952 KB | Output is correct |
2 | Correct | 5 ms | 1372 KB | Output is correct |
3 | Correct | 14 ms | 5428 KB | Output is correct |
4 | Correct | 10 ms | 1116 KB | Output is correct |
5 | Correct | 16 ms | 4332 KB | Output is correct |
6 | Correct | 11 ms | 3420 KB | Output is correct |
7 | Correct | 3 ms | 1628 KB | Output is correct |
8 | Correct | 11 ms | 3928 KB | Output is correct |
9 | Correct | 25 ms | 3404 KB | Output is correct |
10 | Correct | 14 ms | 3160 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 416 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 416 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 7 ms | 860 KB | Output is correct |
17 | Correct | 17 ms | 1788 KB | Output is correct |
18 | Correct | 22 ms | 1884 KB | Output is correct |
19 | Correct | 40 ms | 1880 KB | Output is correct |
20 | Correct | 44 ms | 1880 KB | Output is correct |
21 | Correct | 16 ms | 1624 KB | Output is correct |
22 | Correct | 1 ms | 548 KB | Output is correct |
23 | Correct | 12 ms | 1116 KB | Output is correct |
24 | Correct | 20 ms | 1880 KB | Output is correct |
25 | Correct | 3 ms | 600 KB | Output is correct |
26 | Correct | 13 ms | 1356 KB | Output is correct |
27 | Correct | 18 ms | 1372 KB | Output is correct |
28 | Correct | 23 ms | 1884 KB | Output is correct |
29 | Correct | 7 ms | 860 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 4952 KB | Output is correct |
2 | Correct | 5 ms | 1372 KB | Output is correct |
3 | Correct | 14 ms | 5428 KB | Output is correct |
4 | Correct | 10 ms | 1116 KB | Output is correct |
5 | Correct | 16 ms | 4332 KB | Output is correct |
6 | Correct | 11 ms | 3420 KB | Output is correct |
7 | Correct | 3 ms | 1628 KB | Output is correct |
8 | Correct | 11 ms | 3928 KB | Output is correct |
9 | Correct | 25 ms | 3404 KB | Output is correct |
10 | Correct | 14 ms | 3160 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 416 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 7 ms | 860 KB | Output is correct |
27 | Correct | 17 ms | 1788 KB | Output is correct |
28 | Correct | 22 ms | 1884 KB | Output is correct |
29 | Correct | 40 ms | 1880 KB | Output is correct |
30 | Correct | 44 ms | 1880 KB | Output is correct |
31 | Correct | 16 ms | 1624 KB | Output is correct |
32 | Correct | 1 ms | 548 KB | Output is correct |
33 | Correct | 12 ms | 1116 KB | Output is correct |
34 | Correct | 20 ms | 1880 KB | Output is correct |
35 | Correct | 3 ms | 600 KB | Output is correct |
36 | Correct | 13 ms | 1356 KB | Output is correct |
37 | Correct | 18 ms | 1372 KB | Output is correct |
38 | Correct | 23 ms | 1884 KB | Output is correct |
39 | Correct | 7 ms | 860 KB | Output is correct |
40 | Correct | 1 ms | 348 KB | Output is correct |
41 | Incorrect | 48 ms | 6996 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 18 ms | 4952 KB | Output is correct |
10 | Correct | 5 ms | 1372 KB | Output is correct |
11 | Correct | 14 ms | 5428 KB | Output is correct |
12 | Correct | 10 ms | 1116 KB | Output is correct |
13 | Correct | 16 ms | 4332 KB | Output is correct |
14 | Correct | 11 ms | 3420 KB | Output is correct |
15 | Correct | 3 ms | 1628 KB | Output is correct |
16 | Correct | 11 ms | 3928 KB | Output is correct |
17 | Correct | 25 ms | 3404 KB | Output is correct |
18 | Correct | 14 ms | 3160 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 416 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 1 ms | 348 KB | Output is correct |
34 | Correct | 7 ms | 860 KB | Output is correct |
35 | Correct | 17 ms | 1788 KB | Output is correct |
36 | Correct | 22 ms | 1884 KB | Output is correct |
37 | Correct | 40 ms | 1880 KB | Output is correct |
38 | Correct | 44 ms | 1880 KB | Output is correct |
39 | Correct | 16 ms | 1624 KB | Output is correct |
40 | Correct | 1 ms | 548 KB | Output is correct |
41 | Correct | 12 ms | 1116 KB | Output is correct |
42 | Correct | 20 ms | 1880 KB | Output is correct |
43 | Correct | 3 ms | 600 KB | Output is correct |
44 | Correct | 13 ms | 1356 KB | Output is correct |
45 | Correct | 18 ms | 1372 KB | Output is correct |
46 | Correct | 23 ms | 1884 KB | Output is correct |
47 | Correct | 7 ms | 860 KB | Output is correct |
48 | Correct | 1 ms | 348 KB | Output is correct |
49 | Incorrect | 48 ms | 6996 KB | Output isn't correct |
50 | Halted | 0 ms | 0 KB | - |