# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378531 | 2021-03-17T01:31:16 Z | ElaineHuang | Chessboard (IZhO18_chessboard) | C++14 | 83 ms | 512 KB |
#include<bits/stdc++.h> #define debug 0 //#define int long long using namespace std; int b[10005][2];//black squares vector<int> factor; int N; 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("%d %d",&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.push_back(i); } if(debug) printf("i=%d\n",i);// } if(debug) printf("%d, g%d\n",factor.size(),g);// while(K--) { scanf("%d %d %d %d",&x1,&y1,&x2,&y2); x1--,y1--,x2--,y2--; for(int i=0;i<factor.size();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<factor.size();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("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 368 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 448 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 16 ms | 364 KB | Output is correct |
17 | Correct | 41 ms | 364 KB | Output is correct |
18 | Correct | 36 ms | 364 KB | Output is correct |
19 | Correct | 82 ms | 448 KB | Output is correct |
20 | Correct | 83 ms | 364 KB | Output is correct |
21 | Correct | 26 ms | 492 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 19 ms | 364 KB | Output is correct |
24 | Correct | 51 ms | 364 KB | Output is correct |
25 | Correct | 4 ms | 364 KB | Output is correct |
26 | Correct | 21 ms | 364 KB | Output is correct |
27 | Correct | 28 ms | 448 KB | Output is correct |
28 | Correct | 48 ms | 364 KB | Output is correct |
29 | Correct | 18 ms | 452 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 448 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 368 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Incorrect | 24 ms | 448 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |