답안 #898336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898336 2024-01-04T14:02:43 Z marcid Chessboard (IZhO18_chessboard) C++17
0 / 100
16 ms 3280 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct rect {
    ll x1, y1, x2, y2;
};
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    vector<rect> a;
    ll n, k;
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        a.push_back({x1, y1, x2, y2});
    }
 
    ll res = n * n;
    ll wh_cnt[n + 1], bl_cnt[n + 1];
    for (int d = 2; d < n; d++) {
        if (n % d) continue;
 
        wh_cnt[0] = 0;
        bl_cnt[0] = 0;
        for (int i = 1; i <= n; i++) {
            int id = (i + d - 1) / d;
            wh_cnt[i] = wh_cnt[i - 1];
            bl_cnt[i] = bl_cnt[i - 1];
            if (id % 2) {
                wh_cnt[i]++;
            } else {
                bl_cnt[i]++;
            }
        }
        
        ll cur = (n / d) * (n / d) / 2 * d * d;
        for (auto [x1, y1, x2, y2] : a) {
            cur += (wh_cnt[x2] - wh_cnt[x1 - 1]) * (wh_cnt[y2] - wh_cnt[y1 - 1]) + (bl_cnt[x2] - bl_cnt[x1 - 1]) * (bl_cnt[y2] - bl_cnt[y1 - 1]);
            cur -= (wh_cnt[x2] - wh_cnt[x1 - 1]) * (bl_cnt[y2] - bl_cnt[y1 - 1]) + (bl_cnt[x2] - bl_cnt[x1 - 1]) * (wh_cnt[y2] - wh_cnt[y1 - 1]);
        }
        res = min({res, cur, n * n - cur});
    }
 
    cout << res << '\n';
 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 3280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 3280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -