제출 #153924

#제출 시각아이디문제언어결과실행 시간메모리
153924theboatmanChessboard (IZhO18_chessboard)C++17
70 / 100
664 ms5804 KiB
#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: ???
*/

컴파일 시 표준 에러 (stderr) 메시지

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;
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...