Submission #334375

#TimeUsernameProblemLanguageResultExecution timeMemory
334375juggernautChessboard (IZhO18_chessboard)C++14
70 / 100
471 ms3564 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; struct Rect{ ll x,y,x2,y2; void _minus(){ x--,y--,x2--,y2--; } }rect[100005]; ll n,m; ll solve(ll side,bool color){ ll sz=n/side; if(color){ ll wh=0,bl=side*side*((sz*sz+1)>>1); for(ll i=0;i<m;i++){ ll block_x=rect[i].x/side; ll 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(ll i=0;i<m;i++){ bool cl; ll block_x=rect[i].x/side; ll block_y=rect[i].y/side; if((block_x+block_y)&1)bl--; else wh++; } return wh+bl; } } int main(){ scanf("%lld%lld",&n,&m); for(ll i=0;i<m;i++)scanf("%lld%lld%lld%lld",&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(ll 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 (stderr)

chessboard.cpp: In function 'll solve(ll, bool)':
chessboard.cpp:25:18: warning: unused variable 'cl' [-Wunused-variable]
   25 |             bool cl;
      |                  ^~
chessboard.cpp: In function 'int main()':
chessboard.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
chessboard.cpp:36:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |     for(ll i=0;i<m;i++)scanf("%lld%lld%lld%lld",&rect[i].x,&rect[i].y,&rect[i].x2,&rect[i].y2),rect[i]._minus();
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...