답안 #674818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674818 2022-12-26T09:15:26 Z LucaIlie Chessboard (IZhO18_chessboard) C++17
70 / 100
378 ms 4232 KB
#include <bits/stdc++.h>

using namespace std;

const int maxK = 1e5;

struct rectangle {
    int l1, c1, l2, c2;
};

rectangle black[maxK];

int main() {
    int n, k;
    long long cost, minCost;

    cin >> n >> k;
    for ( int i = 0; i < k; i++ )
        cin >> black[i].l1 >> black[i].c1 >> black[i].l2 >> black[i].c2;

    minCost = (long long)n * n;
    for ( int l = 1; l < n; l++ ) {
        if ( n % l == 0 ) {
            int x = (n / l + 1) / 2, y = n / l / 2;

            cost = ((long long)l * l) * ((long long)x * x + (long long)y * y);
            for ( int i = 0; i < k; i++ ) {
                int lin = (black[i].l1 - 1) / l;
                int col = (black[i].c1 - 1) / l;

                if ( (lin + col) % 2 == 0 )
                    cost--;
                else
                    cost++;
            }
            minCost = min( minCost, cost );

            cost = (long long)2 * x * y * l * l;
            for ( int i = 0; i < k; i++ ) {
                int lin = (black[i].l1 - 1) / l;
                int col = (black[i].c1 - 1) / l;

                if ( (lin + col) % 2 == 0 )
                    cost++;
                else
                    cost--;
            }
            minCost = min( minCost, cost );
        }
    }

    cout << minCost;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 2752 KB Output is correct
2 Correct 17 ms 920 KB Output is correct
3 Correct 42 ms 1816 KB Output is correct
4 Correct 43 ms 1788 KB Output is correct
5 Correct 66 ms 2412 KB Output is correct
6 Correct 36 ms 1544 KB Output is correct
7 Correct 8 ms 468 KB Output is correct
8 Correct 39 ms 1652 KB Output is correct
9 Correct 96 ms 3660 KB Output is correct
10 Correct 55 ms 2208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 24 ms 1164 KB Output is correct
17 Correct 68 ms 2844 KB Output is correct
18 Correct 82 ms 3424 KB Output is correct
19 Correct 116 ms 3032 KB Output is correct
20 Correct 129 ms 3404 KB Output is correct
21 Correct 69 ms 2932 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 39 ms 1516 KB Output is correct
24 Correct 74 ms 3036 KB Output is correct
25 Correct 8 ms 468 KB Output is correct
26 Correct 47 ms 2016 KB Output is correct
27 Correct 67 ms 2376 KB Output is correct
28 Correct 83 ms 3388 KB Output is correct
29 Correct 27 ms 1312 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 2752 KB Output is correct
2 Correct 17 ms 920 KB Output is correct
3 Correct 42 ms 1816 KB Output is correct
4 Correct 43 ms 1788 KB Output is correct
5 Correct 66 ms 2412 KB Output is correct
6 Correct 36 ms 1544 KB Output is correct
7 Correct 8 ms 468 KB Output is correct
8 Correct 39 ms 1652 KB Output is correct
9 Correct 96 ms 3660 KB Output is correct
10 Correct 55 ms 2208 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 308 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 24 ms 1164 KB Output is correct
27 Correct 68 ms 2844 KB Output is correct
28 Correct 82 ms 3424 KB Output is correct
29 Correct 116 ms 3032 KB Output is correct
30 Correct 129 ms 3404 KB Output is correct
31 Correct 69 ms 2932 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 39 ms 1516 KB Output is correct
34 Correct 74 ms 3036 KB Output is correct
35 Correct 8 ms 468 KB Output is correct
36 Correct 47 ms 2016 KB Output is correct
37 Correct 67 ms 2376 KB Output is correct
38 Correct 83 ms 3388 KB Output is correct
39 Correct 27 ms 1312 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Correct 125 ms 3556 KB Output is correct
42 Correct 102 ms 4012 KB Output is correct
43 Correct 104 ms 3536 KB Output is correct
44 Correct 99 ms 3868 KB Output is correct
45 Correct 101 ms 4080 KB Output is correct
46 Correct 141 ms 3960 KB Output is correct
47 Correct 88 ms 3636 KB Output is correct
48 Correct 103 ms 3728 KB Output is correct
49 Correct 93 ms 3512 KB Output is correct
50 Correct 342 ms 3864 KB Output is correct
51 Correct 366 ms 4168 KB Output is correct
52 Correct 340 ms 3784 KB Output is correct
53 Correct 367 ms 4048 KB Output is correct
54 Correct 335 ms 3720 KB Output is correct
55 Correct 378 ms 4232 KB Output is correct
56 Correct 327 ms 3672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 70 ms 2752 KB Output is correct
10 Correct 17 ms 920 KB Output is correct
11 Correct 42 ms 1816 KB Output is correct
12 Correct 43 ms 1788 KB Output is correct
13 Correct 66 ms 2412 KB Output is correct
14 Correct 36 ms 1544 KB Output is correct
15 Correct 8 ms 468 KB Output is correct
16 Correct 39 ms 1652 KB Output is correct
17 Correct 96 ms 3660 KB Output is correct
18 Correct 55 ms 2208 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 308 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 308 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 312 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 24 ms 1164 KB Output is correct
35 Correct 68 ms 2844 KB Output is correct
36 Correct 82 ms 3424 KB Output is correct
37 Correct 116 ms 3032 KB Output is correct
38 Correct 129 ms 3404 KB Output is correct
39 Correct 69 ms 2932 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 39 ms 1516 KB Output is correct
42 Correct 74 ms 3036 KB Output is correct
43 Correct 8 ms 468 KB Output is correct
44 Correct 47 ms 2016 KB Output is correct
45 Correct 67 ms 2376 KB Output is correct
46 Correct 83 ms 3388 KB Output is correct
47 Correct 27 ms 1312 KB Output is correct
48 Correct 3 ms 340 KB Output is correct
49 Correct 125 ms 3556 KB Output is correct
50 Correct 102 ms 4012 KB Output is correct
51 Correct 104 ms 3536 KB Output is correct
52 Correct 99 ms 3868 KB Output is correct
53 Correct 101 ms 4080 KB Output is correct
54 Correct 141 ms 3960 KB Output is correct
55 Correct 88 ms 3636 KB Output is correct
56 Correct 103 ms 3728 KB Output is correct
57 Correct 93 ms 3512 KB Output is correct
58 Correct 342 ms 3864 KB Output is correct
59 Correct 366 ms 4168 KB Output is correct
60 Correct 340 ms 3784 KB Output is correct
61 Correct 367 ms 4048 KB Output is correct
62 Correct 335 ms 3720 KB Output is correct
63 Correct 378 ms 4232 KB Output is correct
64 Correct 327 ms 3672 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Incorrect 0 ms 212 KB Output isn't correct
67 Halted 0 ms 0 KB -