답안 #850949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850949 2023-09-18T02:26:12 Z wakandaaa Chessboard (IZhO18_chessboard) C++17
70 / 100
159 ms 8400 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

#define file ""

#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()

#define getbit(x, i) (((x) >> (i)) & 1)
#define bit(x) (1LL << (x))
#define popcount __builtin_popcountll

mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
    return l + rd() % (r - l + 1);
}

const int N = 1e6 + 5;
const int mod = (int)1e9 + 7; // 998244353;
const int lg = 25; // lg + 1
const int oo = 1e9;
const long long ooo = 1e18;

template<class X, class Y> bool mini(X &a, Y b) {
    return a > b ? (a = b, true) : false;
}
template<class X, class Y> bool maxi(X &a, Y b) {
    return a < b ? (a = b, true) : false;
}
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    if (a < 0) a += mod;
}

struct rec {
	int x, y, u, v;
	rec (int _x = 0, int _y = 0, int _u = 0, int _v = 0) {
		x = _x;
		y = _y;
		u = _u;
		v = _v;
	}
};
int n, k;
vector<rec> subrec;
int area = 0;
int res = ooo;

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

    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);

    cin >> n >> k;
    for (int i = 1; i <= k; ++i) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        --x, --y, --u, --v;
        subrec.push_back(rec(x, y, u, v));
        area += (u - x + 1) * (v - y + 1);
    }
    for (int i = 1; i < n; ++i) if (n % i == 0) {
        int d = n / i;
        int a = (d * d + 1) / 2 * i * i;
        int b = (d * d) / 2 * i * i;
        int cnt = 0;
        for (auto [x, y, u, v] : subrec) {
            if ((x / i) % 2 == (y / i) % 2) ++cnt;
        }     
        res = min(res, (a - cnt) + (area - cnt));
        res = min(res, (b - (area - cnt)) + cnt);
    }

    cout << res;

    return 0;
}

/*

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 548 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 4040 KB Output is correct
2 Correct 5 ms 1756 KB Output is correct
3 Correct 11 ms 3544 KB Output is correct
4 Correct 12 ms 3288 KB Output is correct
5 Correct 15 ms 3540 KB Output is correct
6 Correct 10 ms 3284 KB Output is correct
7 Correct 2 ms 988 KB Output is correct
8 Correct 10 ms 3288 KB Output is correct
9 Correct 25 ms 6600 KB Output is correct
10 Correct 15 ms 3544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 7 ms 2008 KB Output is correct
17 Correct 19 ms 5844 KB Output is correct
18 Correct 24 ms 7120 KB Output is correct
19 Correct 42 ms 5832 KB Output is correct
20 Correct 46 ms 7368 KB Output is correct
21 Correct 19 ms 6860 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 12 ms 3284 KB Output is correct
24 Correct 22 ms 6568 KB Output is correct
25 Correct 3 ms 1244 KB Output is correct
26 Correct 15 ms 3320 KB Output is correct
27 Correct 18 ms 5840 KB Output is correct
28 Correct 23 ms 7380 KB Output is correct
29 Correct 8 ms 3028 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 4040 KB Output is correct
2 Correct 5 ms 1756 KB Output is correct
3 Correct 11 ms 3544 KB Output is correct
4 Correct 12 ms 3288 KB Output is correct
5 Correct 15 ms 3540 KB Output is correct
6 Correct 10 ms 3284 KB Output is correct
7 Correct 2 ms 988 KB Output is correct
8 Correct 10 ms 3288 KB Output is correct
9 Correct 25 ms 6600 KB Output is correct
10 Correct 15 ms 3544 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 7 ms 2008 KB Output is correct
27 Correct 19 ms 5844 KB Output is correct
28 Correct 24 ms 7120 KB Output is correct
29 Correct 42 ms 5832 KB Output is correct
30 Correct 46 ms 7368 KB Output is correct
31 Correct 19 ms 6860 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 12 ms 3284 KB Output is correct
34 Correct 22 ms 6568 KB Output is correct
35 Correct 3 ms 1244 KB Output is correct
36 Correct 15 ms 3320 KB Output is correct
37 Correct 18 ms 5840 KB Output is correct
38 Correct 23 ms 7380 KB Output is correct
39 Correct 8 ms 3028 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 49 ms 7368 KB Output is correct
42 Correct 28 ms 7880 KB Output is correct
43 Correct 31 ms 8400 KB Output is correct
44 Correct 26 ms 8004 KB Output is correct
45 Correct 26 ms 6856 KB Output is correct
46 Correct 47 ms 8140 KB Output is correct
47 Correct 23 ms 7632 KB Output is correct
48 Correct 30 ms 8144 KB Output is correct
49 Correct 24 ms 7376 KB Output is correct
50 Correct 144 ms 6600 KB Output is correct
51 Correct 154 ms 8136 KB Output is correct
52 Correct 144 ms 8392 KB Output is correct
53 Correct 153 ms 7112 KB Output is correct
54 Correct 143 ms 6856 KB Output is correct
55 Correct 159 ms 6600 KB Output is correct
56 Correct 137 ms 6600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 548 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 16 ms 4040 KB Output is correct
10 Correct 5 ms 1756 KB Output is correct
11 Correct 11 ms 3544 KB Output is correct
12 Correct 12 ms 3288 KB Output is correct
13 Correct 15 ms 3540 KB Output is correct
14 Correct 10 ms 3284 KB Output is correct
15 Correct 2 ms 988 KB Output is correct
16 Correct 10 ms 3288 KB Output is correct
17 Correct 25 ms 6600 KB Output is correct
18 Correct 15 ms 3544 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 7 ms 2008 KB Output is correct
35 Correct 19 ms 5844 KB Output is correct
36 Correct 24 ms 7120 KB Output is correct
37 Correct 42 ms 5832 KB Output is correct
38 Correct 46 ms 7368 KB Output is correct
39 Correct 19 ms 6860 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 12 ms 3284 KB Output is correct
42 Correct 22 ms 6568 KB Output is correct
43 Correct 3 ms 1244 KB Output is correct
44 Correct 15 ms 3320 KB Output is correct
45 Correct 18 ms 5840 KB Output is correct
46 Correct 23 ms 7380 KB Output is correct
47 Correct 8 ms 3028 KB Output is correct
48 Correct 1 ms 604 KB Output is correct
49 Correct 49 ms 7368 KB Output is correct
50 Correct 28 ms 7880 KB Output is correct
51 Correct 31 ms 8400 KB Output is correct
52 Correct 26 ms 8004 KB Output is correct
53 Correct 26 ms 6856 KB Output is correct
54 Correct 47 ms 8140 KB Output is correct
55 Correct 23 ms 7632 KB Output is correct
56 Correct 30 ms 8144 KB Output is correct
57 Correct 24 ms 7376 KB Output is correct
58 Correct 144 ms 6600 KB Output is correct
59 Correct 154 ms 8136 KB Output is correct
60 Correct 144 ms 8392 KB Output is correct
61 Correct 153 ms 7112 KB Output is correct
62 Correct 143 ms 6856 KB Output is correct
63 Correct 159 ms 6600 KB Output is correct
64 Correct 137 ms 6600 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Incorrect 1 ms 344 KB Output isn't correct
67 Halted 0 ms 0 KB -