# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334372 | 2020-12-09T05:23:37 Z | juggernaut | Chessboard (IZhO18_chessboard) | C++14 | 116 ms | 2028 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; struct Rect{ int x,y,x2,y2; void _minus(){ x--,y--,x2--,y2--; } }rect[100005]; int n,m; ll solve(int side,bool color){ int sz=n/side; if(color){ ll wh=0,bl=side*side*((sz*sz+1)>>1); for(int i=0;i<m;i++){ int block_x=rect[i].x/side; int block_y=rect[i].y/side; if((block_x+block_y)&1)wh++; else bl--; } return wh+bl; }else{ ll wh=0,bl=side*side*((sz*sz)>>1); for(int i=0;i<m;i++){ bool cl; int block_x=rect[i].x/side; int block_y=rect[i].y/side; if((block_x+block_y)&1)bl--; else wh++; } return wh+bl; } } int main(){ scanf("%d%d",&n,&m); for(int i=0;i<m;i++)scanf("%d%d%d%d",&rect[i].x,&rect[i].y,&rect[i].x2,&rect[i].y2),rect[i]._minus(); ll res=min(solve(1,0),solve(1,1)); for(int i=2;i*i<=n;i++)if(n%i==0)res=min(res,min(min(solve(i,0),solve(n/i,0)),min(solve(i,1),solve(n/i,1)))); printf("%lld",res); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 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 | 26 ms | 1260 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 | 364 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 | 364 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 | 364 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 | 364 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 | 12 ms | 748 KB | Output is correct |
17 | Correct | 30 ms | 1644 KB | Output is correct |
18 | Correct | 41 ms | 1900 KB | Output is correct |
19 | Correct | 104 ms | 1772 KB | Output is correct |
20 | Correct | 116 ms | 2028 KB | Output is correct |
21 | Correct | 28 ms | 1644 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 26 ms | 1132 KB | Output is correct |
24 | Correct | 38 ms | 1772 KB | Output is correct |
25 | Correct | 5 ms | 492 KB | Output is correct |
26 | Correct | 24 ms | 1260 KB | Output is correct |
27 | Correct | 32 ms | 1388 KB | Output is correct |
28 | Correct | 40 ms | 1772 KB | Output is correct |
29 | Correct | 12 ms | 876 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 1260 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 | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 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 | 26 ms | 1260 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |