# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334370 | 2020-12-09T05:20:36 Z | juggernaut | Chessboard (IZhO18_chessboard) | C++14 | 116 ms | 1916 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){ if(side==n)return (9e18); 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=9e18; for(int i=1;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 | 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 | 0 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 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 | 512 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 | 512 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 | 15 ms | 768 KB | Output is correct |
17 | Correct | 30 ms | 1644 KB | Output is correct |
18 | Correct | 42 ms | 1900 KB | Output is correct |
19 | Correct | 104 ms | 1840 KB | Output is correct |
20 | Correct | 116 ms | 1916 KB | Output is correct |
21 | Correct | 31 ms | 1644 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 23 ms | 1004 KB | Output is correct |
24 | Correct | 51 ms | 1772 KB | Output is correct |
25 | Correct | 5 ms | 492 KB | Output is correct |
26 | Correct | 27 ms | 1260 KB | Output is correct |
27 | Correct | 33 ms | 1388 KB | Output is correct |
28 | Correct | 40 ms | 1900 KB | Output is correct |
29 | Correct | 12 ms | 876 KB | Output is correct |
30 | Correct | 3 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 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 | 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 | 0 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Incorrect | 27 ms | 1260 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |