답안 #153924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153924 2019-09-17T13:53:08 Z theboatman Chessboard (IZhO18_chessboard) C++17
70 / 100
664 ms 5804 KB
#include <bits/stdc++.h>

#define y1 theboatman
#define make_struct(args...) {args}

#define int long long

using namespace std;

struct sqr {
    int x, y, x1, y1;
};

int get(int n, int len, vector <sqr> &a) {
    int col_sqr = (n * n) / (len * len);

    int res = (col_sqr / 2) * len * len;
    for(auto i : a) {
        int x = i.x, y = i.y;

        int color = (i.x - 1) / len + (i.y - 1) / len;

        if (color % 2 == 0) {
            res++;
        }
        else {
            res--;
        }
    }

    int res1 = ( (col_sqr + 1) / 2) * len * len;
    for(auto i : a) {
        int x = i.x, y = i.y;

        int color = (i.x - 1) / len + (i.y - 1) / len;

        if (color % 2 == 1) {
            res1++;
        }
        else {
            res1--;
        }
    }

    return min(res, res1);
}

int32_t main() {
    cin.tie(0);
    ios :: sync_with_stdio(0);

    int n, k;
    cin >> n >> k;

    vector <sqr> a(k);
    for(int i = 0; i < k; i++) {
        cin >> a[i].x >> a[i].y >> a[i].x1 >> a[i].y1;
    }

    int ans = n * n;
    for(int i = 1; i < n; i++) {
        if (n % i == 0) {
            ans = min(ans, get(n, i, a));
        }
    }

    cout << ans << "\n";
    return 0;
}
/*
cost: ???
*/

Compilation message

chessboard.cpp: In function 'long long int get(long long int, long long int, std::vector<sqr>&)':
chessboard.cpp:19:13: warning: unused variable 'x' [-Wunused-variable]
         int x = i.x, y = i.y;
             ^
chessboard.cpp:19:22: warning: unused variable 'y' [-Wunused-variable]
         int x = i.x, y = i.y;
                      ^
chessboard.cpp:33:13: warning: unused variable 'x' [-Wunused-variable]
         int x = i.x, y = i.y;
             ^
chessboard.cpp:33:22: warning: unused variable 'y' [-Wunused-variable]
         int x = i.x, y = i.y;
                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 3836 KB Output is correct
2 Correct 11 ms 1144 KB Output is correct
3 Correct 23 ms 2552 KB Output is correct
4 Correct 24 ms 2680 KB Output is correct
5 Correct 30 ms 3400 KB Output is correct
6 Correct 20 ms 2296 KB Output is correct
7 Correct 6 ms 764 KB Output is correct
8 Correct 20 ms 2296 KB Output is correct
9 Correct 49 ms 5240 KB Output is correct
10 Correct 28 ms 3064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 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 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 17 ms 1656 KB Output is correct
17 Correct 41 ms 4292 KB Output is correct
18 Correct 54 ms 5012 KB Output is correct
19 Correct 152 ms 4600 KB Output is correct
20 Correct 169 ms 4984 KB Output is correct
21 Correct 37 ms 4344 KB Output is correct
22 Correct 0 ms 380 KB Output is correct
23 Correct 34 ms 2424 KB Output is correct
24 Correct 49 ms 4600 KB Output is correct
25 Correct 9 ms 812 KB Output is correct
26 Correct 31 ms 3068 KB Output is correct
27 Correct 46 ms 3524 KB Output is correct
28 Correct 52 ms 4936 KB Output is correct
29 Correct 17 ms 1912 KB Output is correct
30 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 3836 KB Output is correct
2 Correct 11 ms 1144 KB Output is correct
3 Correct 23 ms 2552 KB Output is correct
4 Correct 24 ms 2680 KB Output is correct
5 Correct 30 ms 3400 KB Output is correct
6 Correct 20 ms 2296 KB Output is correct
7 Correct 6 ms 764 KB Output is correct
8 Correct 20 ms 2296 KB Output is correct
9 Correct 49 ms 5240 KB Output is correct
10 Correct 28 ms 3064 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 17 ms 1656 KB Output is correct
27 Correct 41 ms 4292 KB Output is correct
28 Correct 54 ms 5012 KB Output is correct
29 Correct 152 ms 4600 KB Output is correct
30 Correct 169 ms 4984 KB Output is correct
31 Correct 37 ms 4344 KB Output is correct
32 Correct 0 ms 380 KB Output is correct
33 Correct 34 ms 2424 KB Output is correct
34 Correct 49 ms 4600 KB Output is correct
35 Correct 9 ms 812 KB Output is correct
36 Correct 31 ms 3068 KB Output is correct
37 Correct 46 ms 3524 KB Output is correct
38 Correct 52 ms 4936 KB Output is correct
39 Correct 17 ms 1912 KB Output is correct
40 Correct 4 ms 504 KB Output is correct
41 Correct 133 ms 4892 KB Output is correct
42 Correct 61 ms 5492 KB Output is correct
43 Correct 86 ms 4936 KB Output is correct
44 Correct 57 ms 5396 KB Output is correct
45 Correct 52 ms 5756 KB Output is correct
46 Correct 148 ms 5448 KB Output is correct
47 Correct 47 ms 5112 KB Output is correct
48 Correct 73 ms 5112 KB Output is correct
49 Correct 53 ms 4984 KB Output is correct
50 Correct 626 ms 5368 KB Output is correct
51 Correct 657 ms 5624 KB Output is correct
52 Correct 620 ms 5240 KB Output is correct
53 Correct 644 ms 5624 KB Output is correct
54 Correct 590 ms 5244 KB Output is correct
55 Correct 664 ms 5804 KB Output is correct
56 Correct 572 ms 5240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 380 KB Output is correct
9 Correct 34 ms 3836 KB Output is correct
10 Correct 11 ms 1144 KB Output is correct
11 Correct 23 ms 2552 KB Output is correct
12 Correct 24 ms 2680 KB Output is correct
13 Correct 30 ms 3400 KB Output is correct
14 Correct 20 ms 2296 KB Output is correct
15 Correct 6 ms 764 KB Output is correct
16 Correct 20 ms 2296 KB Output is correct
17 Correct 49 ms 5240 KB Output is correct
18 Correct 28 ms 3064 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 17 ms 1656 KB Output is correct
35 Correct 41 ms 4292 KB Output is correct
36 Correct 54 ms 5012 KB Output is correct
37 Correct 152 ms 4600 KB Output is correct
38 Correct 169 ms 4984 KB Output is correct
39 Correct 37 ms 4344 KB Output is correct
40 Correct 0 ms 380 KB Output is correct
41 Correct 34 ms 2424 KB Output is correct
42 Correct 49 ms 4600 KB Output is correct
43 Correct 9 ms 812 KB Output is correct
44 Correct 31 ms 3068 KB Output is correct
45 Correct 46 ms 3524 KB Output is correct
46 Correct 52 ms 4936 KB Output is correct
47 Correct 17 ms 1912 KB Output is correct
48 Correct 4 ms 504 KB Output is correct
49 Correct 133 ms 4892 KB Output is correct
50 Correct 61 ms 5492 KB Output is correct
51 Correct 86 ms 4936 KB Output is correct
52 Correct 57 ms 5396 KB Output is correct
53 Correct 52 ms 5756 KB Output is correct
54 Correct 148 ms 5448 KB Output is correct
55 Correct 47 ms 5112 KB Output is correct
56 Correct 73 ms 5112 KB Output is correct
57 Correct 53 ms 4984 KB Output is correct
58 Correct 626 ms 5368 KB Output is correct
59 Correct 657 ms 5624 KB Output is correct
60 Correct 620 ms 5240 KB Output is correct
61 Correct 644 ms 5624 KB Output is correct
62 Correct 590 ms 5244 KB Output is correct
63 Correct 664 ms 5804 KB Output is correct
64 Correct 572 ms 5240 KB Output is correct
65 Correct 2 ms 380 KB Output is correct
66 Incorrect 2 ms 376 KB Output isn't correct
67 Halted 0 ms 0 KB -