# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378562 | 2021-03-17T01:46:42 Z | ElaineHuang | Chessboard (IZhO18_chessboard) | C++14 | 76 ms | 748 KB |
#include<bits/stdc++.h> #define debug 0 #define int long long #define min trash using namespace std; int b[10005][2];//black squares //vector<int> factor; int factor[10005],fs;//factor size int N; int Min(int a,int b) { return a<b?a:b; } int p(int f) { int o=((N/f)*(N/f)/2)*f*f;//o->odd blocks int e=N*N-o;//e->even blocks if(debug) printf("f%d o%d e%d\n",f,o,e);// return Min(b[f][1]+e-b[f][0],b[f][0]+o-b[f][1]);//e黑//o黑 } signed main() { int K,x1,x2,y1,y2; scanf("%lld %lld",&N,&K); int g=(int)sqrt(N); //factor.clear(); memset(b,0,sizeof(b)); for(int i=1;i<=g;i++) { if(!(N%i)) { factor[fs]=i; fs++; } if(debug) printf("i=%d\n",i);// } if(debug) printf("%d, g%d\n",fs,g);// while(K--) { scanf("%lld %lld %lld %lld",&x1,&y1,&x2,&y2); x1--,y1--,x2--,y2--; for(int i=0;i<fs;i++) { int a;//determine 0 or 1 int f;//factor f=factor[i]; a=x1/f+y1/f; a%=2; b[f][a]++; if(f==N/f) break; if(f==1) continue; f=N/factor[i]; a=x1/f+y1/f; a%=2; b[f][a]++; } } int ans=N*N; for(int i=0;i<fs;i++) { int f; f=factor[i];//p->paint幾格 ans=Min(p(f),ans); if(f==N/f) break; if(f==1) continue; f=N/f; ans=Min(p(f),ans); } printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 492 KB | Output is correct |
2 | Correct | 7 ms | 492 KB | Output is correct |
3 | Correct | 16 ms | 492 KB | Output is correct |
4 | Correct | 17 ms | 492 KB | Output is correct |
5 | Correct | 22 ms | 492 KB | Output is correct |
6 | Correct | 14 ms | 492 KB | Output is correct |
7 | Correct | 4 ms | 492 KB | Output is correct |
8 | Correct | 14 ms | 492 KB | Output is correct |
9 | Correct | 35 ms | 492 KB | Output is correct |
10 | Correct | 20 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 11 ms | 492 KB | Output is correct |
17 | Correct | 28 ms | 492 KB | Output is correct |
18 | Correct | 44 ms | 492 KB | Output is correct |
19 | Correct | 69 ms | 492 KB | Output is correct |
20 | Correct | 76 ms | 492 KB | Output is correct |
21 | Correct | 28 ms | 492 KB | Output is correct |
22 | Correct | 1 ms | 492 KB | Output is correct |
23 | Correct | 19 ms | 492 KB | Output is correct |
24 | Correct | 35 ms | 492 KB | Output is correct |
25 | Correct | 4 ms | 492 KB | Output is correct |
26 | Correct | 21 ms | 492 KB | Output is correct |
27 | Correct | 29 ms | 492 KB | Output is correct |
28 | Correct | 37 ms | 492 KB | Output is correct |
29 | Correct | 12 ms | 492 KB | Output is correct |
30 | Correct | 2 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 492 KB | Output is correct |
2 | Correct | 7 ms | 492 KB | Output is correct |
3 | Correct | 16 ms | 492 KB | Output is correct |
4 | Correct | 17 ms | 492 KB | Output is correct |
5 | Correct | 22 ms | 492 KB | Output is correct |
6 | Correct | 14 ms | 492 KB | Output is correct |
7 | Correct | 4 ms | 492 KB | Output is correct |
8 | Correct | 14 ms | 492 KB | Output is correct |
9 | Correct | 35 ms | 492 KB | Output is correct |
10 | Correct | 20 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 512 KB | Output is correct |
16 | Correct | 1 ms | 492 KB | Output is correct |
17 | Correct | 1 ms | 492 KB | Output is correct |
18 | Correct | 1 ms | 492 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 1 ms | 492 KB | Output is correct |
21 | Correct | 1 ms | 492 KB | Output is correct |
22 | Correct | 1 ms | 492 KB | Output is correct |
23 | Correct | 1 ms | 492 KB | Output is correct |
24 | Correct | 1 ms | 492 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 11 ms | 492 KB | Output is correct |
27 | Correct | 28 ms | 492 KB | Output is correct |
28 | Correct | 44 ms | 492 KB | Output is correct |
29 | Correct | 69 ms | 492 KB | Output is correct |
30 | Correct | 76 ms | 492 KB | Output is correct |
31 | Correct | 28 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 19 ms | 492 KB | Output is correct |
34 | Correct | 35 ms | 492 KB | Output is correct |
35 | Correct | 4 ms | 492 KB | Output is correct |
36 | Correct | 21 ms | 492 KB | Output is correct |
37 | Correct | 29 ms | 492 KB | Output is correct |
38 | Correct | 37 ms | 492 KB | Output is correct |
39 | Correct | 12 ms | 492 KB | Output is correct |
40 | Correct | 2 ms | 492 KB | Output is correct |
41 | Runtime error | 1 ms | 748 KB | Execution killed with signal 11 |
42 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 524 KB | Output is correct |
9 | Correct | 28 ms | 492 KB | Output is correct |
10 | Correct | 7 ms | 492 KB | Output is correct |
11 | Correct | 16 ms | 492 KB | Output is correct |
12 | Correct | 17 ms | 492 KB | Output is correct |
13 | Correct | 22 ms | 492 KB | Output is correct |
14 | Correct | 14 ms | 492 KB | Output is correct |
15 | Correct | 4 ms | 492 KB | Output is correct |
16 | Correct | 14 ms | 492 KB | Output is correct |
17 | Correct | 35 ms | 492 KB | Output is correct |
18 | Correct | 20 ms | 492 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 1 ms | 492 KB | Output is correct |
21 | Correct | 1 ms | 492 KB | Output is correct |
22 | Correct | 1 ms | 492 KB | Output is correct |
23 | Correct | 1 ms | 512 KB | Output is correct |
24 | Correct | 1 ms | 492 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 1 ms | 492 KB | Output is correct |
27 | Correct | 1 ms | 492 KB | Output is correct |
28 | Correct | 1 ms | 492 KB | Output is correct |
29 | Correct | 1 ms | 492 KB | Output is correct |
30 | Correct | 1 ms | 492 KB | Output is correct |
31 | Correct | 1 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Correct | 11 ms | 492 KB | Output is correct |
35 | Correct | 28 ms | 492 KB | Output is correct |
36 | Correct | 44 ms | 492 KB | Output is correct |
37 | Correct | 69 ms | 492 KB | Output is correct |
38 | Correct | 76 ms | 492 KB | Output is correct |
39 | Correct | 28 ms | 492 KB | Output is correct |
40 | Correct | 1 ms | 492 KB | Output is correct |
41 | Correct | 19 ms | 492 KB | Output is correct |
42 | Correct | 35 ms | 492 KB | Output is correct |
43 | Correct | 4 ms | 492 KB | Output is correct |
44 | Correct | 21 ms | 492 KB | Output is correct |
45 | Correct | 29 ms | 492 KB | Output is correct |
46 | Correct | 37 ms | 492 KB | Output is correct |
47 | Correct | 12 ms | 492 KB | Output is correct |
48 | Correct | 2 ms | 492 KB | Output is correct |
49 | Runtime error | 1 ms | 748 KB | Execution killed with signal 11 |
50 | Halted | 0 ms | 0 KB | - |