Submission #1117429

# Submission time Handle Problem Language Result Execution time Memory
1117429 2024-11-23T15:02:28 Z Petrix Chessboard (IZhO18_chessboard) C++17
100 / 100
147 ms 4364 KB
#include <iostream>
using namespace std;

int v[100001][4];

#define int long long

int calc(int i,int lun) {
    return i/(2*lun)*lun+min(i%(2*lun),lun);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,a,d,l1,l2,c1,c2,lin,col,i,j,rasp;
    cin>>n>>k;
    for(i=1;i<=k;i++){
        for(j=0;j<4;j++){
            cin>>v[i][j];
        }
    }
    rasp=n*n;
    for(d=1;d<n;d++){
        if(n%d==0){
            a=2*calc(n,d)*(n-calc(n,d));
            for(j=1;j<=k;j++){
                l1=v[j][0];c1=v[j][1];
                l2=v[j][2];c2=v[j][3];
                lin=calc(l2,d)-calc(l1-1,d);col=calc(c2,d)-calc(c1-1,d);
                a+=2*(l2-l1+1-lin)*(c2-c1+1-col)+2*lin*col-(l2-l1+1)*(c2-c1+1);
            }
            rasp=min(rasp,min(n*n-a,a));
        }

    }cout<<rasp;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2896 KB Output is correct
2 Correct 5 ms 848 KB Output is correct
3 Correct 11 ms 1856 KB Output is correct
4 Correct 14 ms 1872 KB Output is correct
5 Correct 21 ms 2384 KB Output is correct
6 Correct 9 ms 1616 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 13 ms 1616 KB Output is correct
9 Correct 31 ms 3912 KB Output is correct
10 Correct 12 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 7 ms 1104 KB Output is correct
17 Correct 17 ms 3080 KB Output is correct
18 Correct 21 ms 3532 KB Output is correct
19 Correct 38 ms 3152 KB Output is correct
20 Correct 50 ms 3496 KB Output is correct
21 Correct 15 ms 2896 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 11 ms 1720 KB Output is correct
24 Correct 19 ms 3152 KB Output is correct
25 Correct 3 ms 592 KB Output is correct
26 Correct 13 ms 2128 KB Output is correct
27 Correct 25 ms 2384 KB Output is correct
28 Correct 21 ms 3408 KB Output is correct
29 Correct 8 ms 1360 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2896 KB Output is correct
2 Correct 5 ms 848 KB Output is correct
3 Correct 11 ms 1856 KB Output is correct
4 Correct 14 ms 1872 KB Output is correct
5 Correct 21 ms 2384 KB Output is correct
6 Correct 9 ms 1616 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 13 ms 1616 KB Output is correct
9 Correct 31 ms 3912 KB Output is correct
10 Correct 12 ms 2384 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 7 ms 1104 KB Output is correct
27 Correct 17 ms 3080 KB Output is correct
28 Correct 21 ms 3532 KB Output is correct
29 Correct 38 ms 3152 KB Output is correct
30 Correct 50 ms 3496 KB Output is correct
31 Correct 15 ms 2896 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 11 ms 1720 KB Output is correct
34 Correct 19 ms 3152 KB Output is correct
35 Correct 3 ms 592 KB Output is correct
36 Correct 13 ms 2128 KB Output is correct
37 Correct 25 ms 2384 KB Output is correct
38 Correct 21 ms 3408 KB Output is correct
39 Correct 8 ms 1360 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 39 ms 3664 KB Output is correct
42 Correct 28 ms 4168 KB Output is correct
43 Correct 28 ms 3560 KB Output is correct
44 Correct 26 ms 3932 KB Output is correct
45 Correct 24 ms 4232 KB Output is correct
46 Correct 48 ms 3948 KB Output is correct
47 Correct 21 ms 3684 KB Output is correct
48 Correct 27 ms 3932 KB Output is correct
49 Correct 23 ms 3676 KB Output is correct
50 Correct 131 ms 4292 KB Output is correct
51 Correct 137 ms 4188 KB Output is correct
52 Correct 136 ms 3920 KB Output is correct
53 Correct 138 ms 4168 KB Output is correct
54 Correct 125 ms 3872 KB Output is correct
55 Correct 147 ms 4364 KB Output is correct
56 Correct 121 ms 3664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 17 ms 2896 KB Output is correct
10 Correct 5 ms 848 KB Output is correct
11 Correct 11 ms 1856 KB Output is correct
12 Correct 14 ms 1872 KB Output is correct
13 Correct 21 ms 2384 KB Output is correct
14 Correct 9 ms 1616 KB Output is correct
15 Correct 3 ms 592 KB Output is correct
16 Correct 13 ms 1616 KB Output is correct
17 Correct 31 ms 3912 KB Output is correct
18 Correct 12 ms 2384 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 7 ms 1104 KB Output is correct
35 Correct 17 ms 3080 KB Output is correct
36 Correct 21 ms 3532 KB Output is correct
37 Correct 38 ms 3152 KB Output is correct
38 Correct 50 ms 3496 KB Output is correct
39 Correct 15 ms 2896 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 11 ms 1720 KB Output is correct
42 Correct 19 ms 3152 KB Output is correct
43 Correct 3 ms 592 KB Output is correct
44 Correct 13 ms 2128 KB Output is correct
45 Correct 25 ms 2384 KB Output is correct
46 Correct 21 ms 3408 KB Output is correct
47 Correct 8 ms 1360 KB Output is correct
48 Correct 1 ms 336 KB Output is correct
49 Correct 39 ms 3664 KB Output is correct
50 Correct 28 ms 4168 KB Output is correct
51 Correct 28 ms 3560 KB Output is correct
52 Correct 26 ms 3932 KB Output is correct
53 Correct 24 ms 4232 KB Output is correct
54 Correct 48 ms 3948 KB Output is correct
55 Correct 21 ms 3684 KB Output is correct
56 Correct 27 ms 3932 KB Output is correct
57 Correct 23 ms 3676 KB Output is correct
58 Correct 131 ms 4292 KB Output is correct
59 Correct 137 ms 4188 KB Output is correct
60 Correct 136 ms 3920 KB Output is correct
61 Correct 138 ms 4168 KB Output is correct
62 Correct 125 ms 3872 KB Output is correct
63 Correct 147 ms 4364 KB Output is correct
64 Correct 121 ms 3664 KB Output is correct
65 Correct 1 ms 336 KB Output is correct
66 Correct 1 ms 336 KB Output is correct
67 Correct 131 ms 4148 KB Output is correct
68 Correct 131 ms 3920 KB Output is correct
69 Correct 120 ms 3664 KB Output is correct
70 Correct 126 ms 3920 KB Output is correct
71 Correct 124 ms 3920 KB Output is correct
72 Correct 120 ms 3832 KB Output is correct
73 Correct 124 ms 3784 KB Output is correct
74 Correct 128 ms 3920 KB Output is correct
75 Correct 121 ms 3916 KB Output is correct
76 Correct 130 ms 4176 KB Output is correct
77 Correct 35 ms 4176 KB Output is correct
78 Correct 31 ms 3912 KB Output is correct
79 Correct 31 ms 3636 KB Output is correct
80 Correct 30 ms 3920 KB Output is correct
81 Correct 28 ms 3600 KB Output is correct
82 Correct 28 ms 3920 KB Output is correct
83 Correct 25 ms 3664 KB Output is correct
84 Correct 86 ms 4272 KB Output is correct
85 Correct 138 ms 4176 KB Output is correct
86 Correct 1 ms 336 KB Output is correct
87 Correct 1 ms 336 KB Output is correct
88 Correct 143 ms 4228 KB Output is correct
89 Correct 28 ms 1000 KB Output is correct
90 Correct 1 ms 336 KB Output is correct