# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
99770 | 2019-03-07T02:53:39 Z | choikiwon | Chessboard (IZhO18_chessboard) | C++17 | 171 ms | 3832 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MN = 100010; int N, K; struct Rect { int r1, c1, r2, c2; }; Rect rect[MN]; int main() { scanf("%d %d", &N, &K); for(int i = 0; i < K; i++) { scanf("%d %d %d %d", &rect[i].r1, &rect[i].c1, &rect[i].r2, &rect[i].c2); rect[i].r1--; rect[i].c1--; rect[i].r2--; rect[i].c2--; } ll mn = 1e18; for(int i = 1; i < N; i++) { if(N % i == 0) { for(int j = 0; j < 2; j++) { int n = N / i; ll tmp = j? (1LL * n * n + 1) / 2 : 1LL * n * n / 2; tmp *= i * i; for(int k = 0; k < K; k++) { int rr = min(rect[k].r2 + 1, (rect[k].r1 + i) / i * i); int cc = min(rect[k].c2 + 1, (rect[k].c1 + i) / i * i); int br = (rect[k].r2 - rr + 1) / (2 * i); int bc = (rect[k].c2 - cc + 1) / (2 * i); if((rect[k].r2 - rr + 1) % (2 * i) > i) br += (rect[k].r2 - rr + 1) % (2 * i) - i; if((rect[k].c2 - cc + 1) % (2 * i) > i) bc += (rect[k].c2 - cc + 1) % (2 * i) - i; br += rr - rect[k].r1; bc += cc - rect[k].c1; int wr = rect[k].r2 - rect[k].r1 + 1 - br; int wc = rect[k].c2 - rect[k].c1 + 1 - bc; if(j ^ ((rect[k].r1 / i + rect[k].c1 / i) & 1)) tmp -= 1LL * (br - wr) * (bc - wc); else tmp += 1LL * (br - wr) * (bc - wc); } mn = min(mn, tmp); } } } printf("%lld", mn); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 368 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2808 KB | Output is correct |
2 | Correct | 10 ms | 1024 KB | Output is correct |
3 | Correct | 20 ms | 1920 KB | Output is correct |
4 | Correct | 20 ms | 1920 KB | Output is correct |
5 | Correct | 30 ms | 2552 KB | Output is correct |
6 | Correct | 18 ms | 1664 KB | Output is correct |
7 | Correct | 7 ms | 640 KB | Output is correct |
8 | Correct | 21 ms | 1792 KB | Output is correct |
9 | Correct | 47 ms | 3832 KB | Output is correct |
10 | Correct | 28 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 15 ms | 1280 KB | Output is correct |
17 | Correct | 39 ms | 3068 KB | Output is correct |
18 | Correct | 72 ms | 3676 KB | Output is correct |
19 | Correct | 148 ms | 3292 KB | Output is correct |
20 | Correct | 171 ms | 3512 KB | Output is correct |
21 | Correct | 38 ms | 2884 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 39 ms | 1664 KB | Output is correct |
24 | Correct | 63 ms | 3192 KB | Output is correct |
25 | Correct | 10 ms | 640 KB | Output is correct |
26 | Correct | 36 ms | 2176 KB | Output is correct |
27 | Correct | 44 ms | 2552 KB | Output is correct |
28 | Correct | 50 ms | 3448 KB | Output is correct |
29 | Correct | 17 ms | 1408 KB | Output is correct |
30 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2808 KB | Output is correct |
2 | Correct | 10 ms | 1024 KB | Output is correct |
3 | Correct | 20 ms | 1920 KB | Output is correct |
4 | Correct | 20 ms | 1920 KB | Output is correct |
5 | Correct | 30 ms | 2552 KB | Output is correct |
6 | Correct | 18 ms | 1664 KB | Output is correct |
7 | Correct | 7 ms | 640 KB | Output is correct |
8 | Correct | 21 ms | 1792 KB | Output is correct |
9 | Correct | 47 ms | 3832 KB | Output is correct |
10 | Correct | 28 ms | 2296 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 3 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 15 ms | 1280 KB | Output is correct |
27 | Correct | 39 ms | 3068 KB | Output is correct |
28 | Correct | 72 ms | 3676 KB | Output is correct |
29 | Correct | 148 ms | 3292 KB | Output is correct |
30 | Correct | 171 ms | 3512 KB | Output is correct |
31 | Correct | 38 ms | 2884 KB | Output is correct |
32 | Correct | 3 ms | 384 KB | Output is correct |
33 | Correct | 39 ms | 1664 KB | Output is correct |
34 | Correct | 63 ms | 3192 KB | Output is correct |
35 | Correct | 10 ms | 640 KB | Output is correct |
36 | Correct | 36 ms | 2176 KB | Output is correct |
37 | Correct | 44 ms | 2552 KB | Output is correct |
38 | Correct | 50 ms | 3448 KB | Output is correct |
39 | Correct | 17 ms | 1408 KB | Output is correct |
40 | Correct | 4 ms | 384 KB | Output is correct |
41 | Incorrect | 130 ms | 3752 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 368 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 30 ms | 2808 KB | Output is correct |
10 | Correct | 10 ms | 1024 KB | Output is correct |
11 | Correct | 20 ms | 1920 KB | Output is correct |
12 | Correct | 20 ms | 1920 KB | Output is correct |
13 | Correct | 30 ms | 2552 KB | Output is correct |
14 | Correct | 18 ms | 1664 KB | Output is correct |
15 | Correct | 7 ms | 640 KB | Output is correct |
16 | Correct | 21 ms | 1792 KB | Output is correct |
17 | Correct | 47 ms | 3832 KB | Output is correct |
18 | Correct | 28 ms | 2296 KB | Output is correct |
19 | Correct | 3 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 256 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 4 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 3 ms | 384 KB | Output is correct |
29 | Correct | 3 ms | 384 KB | Output is correct |
30 | Correct | 3 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 3 ms | 384 KB | Output is correct |
33 | Correct | 3 ms | 384 KB | Output is correct |
34 | Correct | 15 ms | 1280 KB | Output is correct |
35 | Correct | 39 ms | 3068 KB | Output is correct |
36 | Correct | 72 ms | 3676 KB | Output is correct |
37 | Correct | 148 ms | 3292 KB | Output is correct |
38 | Correct | 171 ms | 3512 KB | Output is correct |
39 | Correct | 38 ms | 2884 KB | Output is correct |
40 | Correct | 3 ms | 384 KB | Output is correct |
41 | Correct | 39 ms | 1664 KB | Output is correct |
42 | Correct | 63 ms | 3192 KB | Output is correct |
43 | Correct | 10 ms | 640 KB | Output is correct |
44 | Correct | 36 ms | 2176 KB | Output is correct |
45 | Correct | 44 ms | 2552 KB | Output is correct |
46 | Correct | 50 ms | 3448 KB | Output is correct |
47 | Correct | 17 ms | 1408 KB | Output is correct |
48 | Correct | 4 ms | 384 KB | Output is correct |
49 | Incorrect | 130 ms | 3752 KB | Output isn't correct |
50 | Halted | 0 ms | 0 KB | - |