Submission #926424

# Submission time Handle Problem Language Result Execution time Memory
926424 2024-02-13T00:39:29 Z AlphaMale06 Chessboard (IZhO18_chessboard) C++14
100 / 100
674 ms 5716 KB
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long

struct rect{
    int x1, y1, x2, y2;
};

int d;

int get(int x, int y){
    if(x<=0 || y<=0)return 0;
    int x1=x/d;
    int y1=y/d;
    int ret=0;
    if(x1!=0 && y1!=0){
        if(x1&y1&1)ret+=d*d;
    }
    int rx=x-x1*d;
    int ry=y-y1*d;
    if(rx==0 && ry==0)return ret;
    if(y1&1){
        if(x1&1)ret-=d*rx;
        else ret+=d*rx;
    }
    if(x1&1){
       if(y1&1)ret-=d*ry;
        else ret+=d*ry;
    }
    if((x1+y1)&1)ret-=rx*ry;
    else ret+=rx*ry;

    return ret;
}


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    rect a[k];
    cout << "\n\n";
    for(int i=0; i< k; i++){
        cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
    }
    int ans=1e12;
    for(d=1; d<n; d++){
        if(n%d!=0)continue;
        int flip=d*d*(((n*n)/(d*d)+1)/2);
        for(int i=0; i<k; i++){
            flip-=get(a[i].x2, a[i].y2)+get(a[i].x1-1, a[i].y1-1)-get(a[i].x1-1, a[i].y2)-get(a[i].x2, a[i].y1-1);
        }
        ans=min({ans, flip, n*n-flip});
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2396 KB Output is correct
2 Correct 5 ms 860 KB Output is correct
3 Correct 12 ms 1628 KB Output is correct
4 Correct 13 ms 1884 KB Output is correct
5 Correct 20 ms 2160 KB Output is correct
6 Correct 12 ms 1372 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 11 ms 1544 KB Output is correct
9 Correct 28 ms 3164 KB Output is correct
10 Correct 18 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 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 348 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 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 348 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 10 ms 1116 KB Output is correct
17 Correct 21 ms 2908 KB Output is correct
18 Correct 35 ms 3420 KB Output is correct
19 Correct 130 ms 3188 KB Output is correct
20 Correct 145 ms 3516 KB Output is correct
21 Correct 20 ms 2904 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 27 ms 1780 KB Output is correct
24 Correct 34 ms 3164 KB Output is correct
25 Correct 5 ms 604 KB Output is correct
26 Correct 20 ms 2224 KB Output is correct
27 Correct 30 ms 2396 KB Output is correct
28 Correct 39 ms 3432 KB Output is correct
29 Correct 8 ms 1372 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2396 KB Output is correct
2 Correct 5 ms 860 KB Output is correct
3 Correct 12 ms 1628 KB Output is correct
4 Correct 13 ms 1884 KB Output is correct
5 Correct 20 ms 2160 KB Output is correct
6 Correct 12 ms 1372 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 11 ms 1544 KB Output is correct
9 Correct 28 ms 3164 KB Output is correct
10 Correct 18 ms 1884 KB Output is correct
11 Correct 0 ms 348 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 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
26 Correct 10 ms 1116 KB Output is correct
27 Correct 21 ms 2908 KB Output is correct
28 Correct 35 ms 3420 KB Output is correct
29 Correct 130 ms 3188 KB Output is correct
30 Correct 145 ms 3516 KB Output is correct
31 Correct 20 ms 2904 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 27 ms 1780 KB Output is correct
34 Correct 34 ms 3164 KB Output is correct
35 Correct 5 ms 604 KB Output is correct
36 Correct 20 ms 2224 KB Output is correct
37 Correct 30 ms 2396 KB Output is correct
38 Correct 39 ms 3432 KB Output is correct
39 Correct 8 ms 1372 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 124 ms 3020 KB Output is correct
42 Correct 37 ms 3164 KB Output is correct
43 Correct 70 ms 2820 KB Output is correct
44 Correct 37 ms 3164 KB Output is correct
45 Correct 35 ms 3668 KB Output is correct
46 Correct 128 ms 3164 KB Output is correct
47 Correct 26 ms 2904 KB Output is correct
48 Correct 52 ms 3160 KB Output is correct
49 Correct 33 ms 2908 KB Output is correct
50 Correct 586 ms 3280 KB Output is correct
51 Correct 624 ms 3420 KB Output is correct
52 Correct 586 ms 3164 KB Output is correct
53 Correct 623 ms 3436 KB Output is correct
54 Correct 578 ms 3200 KB Output is correct
55 Correct 647 ms 3556 KB Output is correct
56 Correct 557 ms 2904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 19 ms 2396 KB Output is correct
10 Correct 5 ms 860 KB Output is correct
11 Correct 12 ms 1628 KB Output is correct
12 Correct 13 ms 1884 KB Output is correct
13 Correct 20 ms 2160 KB Output is correct
14 Correct 12 ms 1372 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 11 ms 1544 KB Output is correct
17 Correct 28 ms 3164 KB Output is correct
18 Correct 18 ms 1884 KB Output is correct
19 Correct 0 ms 348 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 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 352 KB Output is correct
34 Correct 10 ms 1116 KB Output is correct
35 Correct 21 ms 2908 KB Output is correct
36 Correct 35 ms 3420 KB Output is correct
37 Correct 130 ms 3188 KB Output is correct
38 Correct 145 ms 3516 KB Output is correct
39 Correct 20 ms 2904 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 27 ms 1780 KB Output is correct
42 Correct 34 ms 3164 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 20 ms 2224 KB Output is correct
45 Correct 30 ms 2396 KB Output is correct
46 Correct 39 ms 3432 KB Output is correct
47 Correct 8 ms 1372 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 124 ms 3020 KB Output is correct
50 Correct 37 ms 3164 KB Output is correct
51 Correct 70 ms 2820 KB Output is correct
52 Correct 37 ms 3164 KB Output is correct
53 Correct 35 ms 3668 KB Output is correct
54 Correct 128 ms 3164 KB Output is correct
55 Correct 26 ms 2904 KB Output is correct
56 Correct 52 ms 3160 KB Output is correct
57 Correct 33 ms 2908 KB Output is correct
58 Correct 586 ms 3280 KB Output is correct
59 Correct 624 ms 3420 KB Output is correct
60 Correct 586 ms 3164 KB Output is correct
61 Correct 623 ms 3436 KB Output is correct
62 Correct 578 ms 3200 KB Output is correct
63 Correct 647 ms 3556 KB Output is correct
64 Correct 557 ms 2904 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 618 ms 3352 KB Output is correct
68 Correct 619 ms 5716 KB Output is correct
69 Correct 540 ms 4924 KB Output is correct
70 Correct 608 ms 5276 KB Output is correct
71 Correct 592 ms 5344 KB Output is correct
72 Correct 584 ms 5252 KB Output is correct
73 Correct 567 ms 5116 KB Output is correct
74 Correct 611 ms 5524 KB Output is correct
75 Correct 590 ms 5296 KB Output is correct
76 Correct 627 ms 5628 KB Output is correct
77 Correct 100 ms 5672 KB Output is correct
78 Correct 37 ms 5204 KB Output is correct
79 Correct 69 ms 5100 KB Output is correct
80 Correct 72 ms 5204 KB Output is correct
81 Correct 66 ms 4948 KB Output is correct
82 Correct 57 ms 5456 KB Output is correct
83 Correct 47 ms 5212 KB Output is correct
84 Correct 371 ms 5712 KB Output is correct
85 Correct 652 ms 5712 KB Output is correct
86 Correct 1 ms 344 KB Output is correct
87 Correct 1 ms 344 KB Output is correct
88 Correct 674 ms 5700 KB Output is correct
89 Correct 129 ms 1616 KB Output is correct
90 Correct 1 ms 344 KB Output is correct