Submission #334387

#TimeUsernameProblemLanguageResultExecution timeMemory
334387juggernautChessboard (IZhO18_chessboard)C++14
70 / 100
202 ms4108 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){ ll sz=n/side; ll ans=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)ans++; else ans--; } return min(ans,n*n-ans); } 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=solve(1); for(ll i=2;i*i<=n;i++)if(n%i==0)res=min(res,min(solve(i),solve(n/i))); printf("%lld",res); }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
chessboard.cpp:24:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |     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...