# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378581 | 2021-03-17T01:57:03 Z | daniel920712 | Chessboard (IZhO18_chessboard) | C++14 | 1854 ms | 262148 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> #include <map> #include <set> #include <algorithm> using namespace std; vector < long long > have; long long con1[100005]; long long con2[100005]; vector < pair < long long , long long > > con[100005]; set < pair < long long , long long > > vis; int main() { long long N,M,ans=1e18,t,a,b,c,d,i,j,k,x,y,m,n; scanf("%lld %lld",&N,&M); for(i=1;i<N;i++) { if(N%i==0) { have.push_back(i); con1[i]=(N/i)*(N/i)/2; con2[i]=(N/i)*(N/i)/2+(N/i)*(N/i)%2; } } while(M--) { scanf("%lld %lld %lld %lld",&a,&b,&c,&d); for(i=a;i<=c;i++) { for(j=b;j<=d;j++) { if(vis.find(make_pair(i,j))!=vis.end()) continue; vis.insert(make_pair(i,j)); for(auto k:have) { x=(i-1)/k; y=(j-1)/k; con[k].push_back(make_pair(x,y)); } } } } for(auto i:have) { sort(con[i].begin(),con[i].end()); M=con[i].size(); x=y=0; m=n=0; for(j=0;j<M;j++) { if(j==0||con[i][j]!=con[i][j-1]) { if((con[i][j].first+con[i][j].second)%2) { con1[i]--; x++; } else { con2[i]--; y++; } } if((con[i][j].first+con[i][j].second)%2) m++; else n++; } a=con1[i]*i*i; a+=x*i*i-m; a+=n; ans=min(ans,a); a=con2[i]*i*i; a+=y*i*i-n; a+=m; ans=min(ans,a); } printf("%lld\n",ans); return 0; } /* 6 8 3 3 3 3 1 2 1 2 3 4 3 4 5 5 5 5 4 3 4 3 4 4 4 4 2 1 2 1 3 6 3 6 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 3 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 7520 KB | Output is correct |
2 | Correct | 18 ms | 4200 KB | Output is correct |
3 | Correct | 42 ms | 5732 KB | Output is correct |
4 | Correct | 48 ms | 6240 KB | Output is correct |
5 | Correct | 58 ms | 6880 KB | Output is correct |
6 | Correct | 35 ms | 5732 KB | Output is correct |
7 | Correct | 9 ms | 3308 KB | Output is correct |
8 | Correct | 47 ms | 5732 KB | Output is correct |
9 | Correct | 107 ms | 9692 KB | Output is correct |
10 | Correct | 58 ms | 6624 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2796 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2796 KB | Output is correct |
4 | Correct | 5 ms | 2796 KB | Output is correct |
5 | Correct | 3 ms | 2796 KB | Output is correct |
6 | Correct | 3 ms | 2796 KB | Output is correct |
7 | Correct | 3 ms | 2796 KB | Output is correct |
8 | Correct | 3 ms | 2796 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Correct | 3 ms | 2796 KB | Output is correct |
12 | Correct | 3 ms | 2668 KB | Output is correct |
13 | Correct | 4 ms | 2796 KB | Output is correct |
14 | Correct | 3 ms | 2796 KB | Output is correct |
15 | Correct | 3 ms | 2796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2796 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2796 KB | Output is correct |
4 | Correct | 5 ms | 2796 KB | Output is correct |
5 | Correct | 3 ms | 2796 KB | Output is correct |
6 | Correct | 3 ms | 2796 KB | Output is correct |
7 | Correct | 3 ms | 2796 KB | Output is correct |
8 | Correct | 3 ms | 2796 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Correct | 3 ms | 2796 KB | Output is correct |
12 | Correct | 3 ms | 2668 KB | Output is correct |
13 | Correct | 4 ms | 2796 KB | Output is correct |
14 | Correct | 3 ms | 2796 KB | Output is correct |
15 | Correct | 3 ms | 2796 KB | Output is correct |
16 | Correct | 35 ms | 5720 KB | Output is correct |
17 | Correct | 98 ms | 9308 KB | Output is correct |
18 | Correct | 154 ms | 13656 KB | Output is correct |
19 | Correct | 379 ms | 45688 KB | Output is correct |
20 | Correct | 422 ms | 50684 KB | Output is correct |
21 | Correct | 88 ms | 9052 KB | Output is correct |
22 | Correct | 3 ms | 2796 KB | Output is correct |
23 | Correct | 75 ms | 10024 KB | Output is correct |
24 | Correct | 121 ms | 12608 KB | Output is correct |
25 | Correct | 15 ms | 4444 KB | Output is correct |
26 | Correct | 75 ms | 8908 KB | Output is correct |
27 | Correct | 104 ms | 12980 KB | Output is correct |
28 | Correct | 129 ms | 13120 KB | Output is correct |
29 | Correct | 34 ms | 5860 KB | Output is correct |
30 | Correct | 5 ms | 3052 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 7520 KB | Output is correct |
2 | Correct | 18 ms | 4200 KB | Output is correct |
3 | Correct | 42 ms | 5732 KB | Output is correct |
4 | Correct | 48 ms | 6240 KB | Output is correct |
5 | Correct | 58 ms | 6880 KB | Output is correct |
6 | Correct | 35 ms | 5732 KB | Output is correct |
7 | Correct | 9 ms | 3308 KB | Output is correct |
8 | Correct | 47 ms | 5732 KB | Output is correct |
9 | Correct | 107 ms | 9692 KB | Output is correct |
10 | Correct | 58 ms | 6624 KB | Output is correct |
11 | Correct | 3 ms | 2796 KB | Output is correct |
12 | Correct | 2 ms | 2668 KB | Output is correct |
13 | Correct | 2 ms | 2796 KB | Output is correct |
14 | Correct | 5 ms | 2796 KB | Output is correct |
15 | Correct | 3 ms | 2796 KB | Output is correct |
16 | Correct | 3 ms | 2796 KB | Output is correct |
17 | Correct | 3 ms | 2796 KB | Output is correct |
18 | Correct | 3 ms | 2796 KB | Output is correct |
19 | Correct | 2 ms | 2668 KB | Output is correct |
20 | Correct | 2 ms | 2668 KB | Output is correct |
21 | Correct | 3 ms | 2796 KB | Output is correct |
22 | Correct | 3 ms | 2668 KB | Output is correct |
23 | Correct | 4 ms | 2796 KB | Output is correct |
24 | Correct | 3 ms | 2796 KB | Output is correct |
25 | Correct | 3 ms | 2796 KB | Output is correct |
26 | Correct | 35 ms | 5720 KB | Output is correct |
27 | Correct | 98 ms | 9308 KB | Output is correct |
28 | Correct | 154 ms | 13656 KB | Output is correct |
29 | Correct | 379 ms | 45688 KB | Output is correct |
30 | Correct | 422 ms | 50684 KB | Output is correct |
31 | Correct | 88 ms | 9052 KB | Output is correct |
32 | Correct | 3 ms | 2796 KB | Output is correct |
33 | Correct | 75 ms | 10024 KB | Output is correct |
34 | Correct | 121 ms | 12608 KB | Output is correct |
35 | Correct | 15 ms | 4444 KB | Output is correct |
36 | Correct | 75 ms | 8908 KB | Output is correct |
37 | Correct | 104 ms | 12980 KB | Output is correct |
38 | Correct | 129 ms | 13120 KB | Output is correct |
39 | Correct | 34 ms | 5860 KB | Output is correct |
40 | Correct | 5 ms | 3052 KB | Output is correct |
41 | Correct | 341 ms | 37948 KB | Output is correct |
42 | Correct | 137 ms | 12992 KB | Output is correct |
43 | Correct | 210 ms | 22468 KB | Output is correct |
44 | Correct | 127 ms | 12752 KB | Output is correct |
45 | Correct | 115 ms | 10332 KB | Output is correct |
46 | Correct | 386 ms | 42012 KB | Output is correct |
47 | Correct | 98 ms | 9436 KB | Output is correct |
48 | Correct | 175 ms | 17676 KB | Output is correct |
49 | Correct | 116 ms | 11840 KB | Output is correct |
50 | Correct | 1671 ms | 191528 KB | Output is correct |
51 | Correct | 1779 ms | 203192 KB | Output is correct |
52 | Correct | 1678 ms | 190632 KB | Output is correct |
53 | Correct | 1821 ms | 202696 KB | Output is correct |
54 | Correct | 1641 ms | 188148 KB | Output is correct |
55 | Correct | 1854 ms | 209896 KB | Output is correct |
56 | Correct | 1611 ms | 182952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 3 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 85 ms | 7520 KB | Output is correct |
10 | Correct | 18 ms | 4200 KB | Output is correct |
11 | Correct | 42 ms | 5732 KB | Output is correct |
12 | Correct | 48 ms | 6240 KB | Output is correct |
13 | Correct | 58 ms | 6880 KB | Output is correct |
14 | Correct | 35 ms | 5732 KB | Output is correct |
15 | Correct | 9 ms | 3308 KB | Output is correct |
16 | Correct | 47 ms | 5732 KB | Output is correct |
17 | Correct | 107 ms | 9692 KB | Output is correct |
18 | Correct | 58 ms | 6624 KB | Output is correct |
19 | Correct | 3 ms | 2796 KB | Output is correct |
20 | Correct | 2 ms | 2668 KB | Output is correct |
21 | Correct | 2 ms | 2796 KB | Output is correct |
22 | Correct | 5 ms | 2796 KB | Output is correct |
23 | Correct | 3 ms | 2796 KB | Output is correct |
24 | Correct | 3 ms | 2796 KB | Output is correct |
25 | Correct | 3 ms | 2796 KB | Output is correct |
26 | Correct | 3 ms | 2796 KB | Output is correct |
27 | Correct | 2 ms | 2668 KB | Output is correct |
28 | Correct | 2 ms | 2668 KB | Output is correct |
29 | Correct | 3 ms | 2796 KB | Output is correct |
30 | Correct | 3 ms | 2668 KB | Output is correct |
31 | Correct | 4 ms | 2796 KB | Output is correct |
32 | Correct | 3 ms | 2796 KB | Output is correct |
33 | Correct | 3 ms | 2796 KB | Output is correct |
34 | Correct | 35 ms | 5720 KB | Output is correct |
35 | Correct | 98 ms | 9308 KB | Output is correct |
36 | Correct | 154 ms | 13656 KB | Output is correct |
37 | Correct | 379 ms | 45688 KB | Output is correct |
38 | Correct | 422 ms | 50684 KB | Output is correct |
39 | Correct | 88 ms | 9052 KB | Output is correct |
40 | Correct | 3 ms | 2796 KB | Output is correct |
41 | Correct | 75 ms | 10024 KB | Output is correct |
42 | Correct | 121 ms | 12608 KB | Output is correct |
43 | Correct | 15 ms | 4444 KB | Output is correct |
44 | Correct | 75 ms | 8908 KB | Output is correct |
45 | Correct | 104 ms | 12980 KB | Output is correct |
46 | Correct | 129 ms | 13120 KB | Output is correct |
47 | Correct | 34 ms | 5860 KB | Output is correct |
48 | Correct | 5 ms | 3052 KB | Output is correct |
49 | Correct | 341 ms | 37948 KB | Output is correct |
50 | Correct | 137 ms | 12992 KB | Output is correct |
51 | Correct | 210 ms | 22468 KB | Output is correct |
52 | Correct | 127 ms | 12752 KB | Output is correct |
53 | Correct | 115 ms | 10332 KB | Output is correct |
54 | Correct | 386 ms | 42012 KB | Output is correct |
55 | Correct | 98 ms | 9436 KB | Output is correct |
56 | Correct | 175 ms | 17676 KB | Output is correct |
57 | Correct | 116 ms | 11840 KB | Output is correct |
58 | Correct | 1671 ms | 191528 KB | Output is correct |
59 | Correct | 1779 ms | 203192 KB | Output is correct |
60 | Correct | 1678 ms | 190632 KB | Output is correct |
61 | Correct | 1821 ms | 202696 KB | Output is correct |
62 | Correct | 1641 ms | 188148 KB | Output is correct |
63 | Correct | 1854 ms | 209896 KB | Output is correct |
64 | Correct | 1611 ms | 182952 KB | Output is correct |
65 | Correct | 2 ms | 2672 KB | Output is correct |
66 | Correct | 2 ms | 2668 KB | Output is correct |
67 | Runtime error | 544 ms | 262148 KB | Execution killed with signal 9 |
68 | Halted | 0 ms | 0 KB | - |