Submission #168428

#TimeUsernameProblemLanguageResultExecution timeMemory
168428juggernautChessboard (IZhO18_chessboard)C++14
8 / 100
47 ms2040 KiB
#include<bits/stdc++.h> #define int long long int #define fr first #define sc second using namespace std; int n,k,i,j,x,y,res; pair<int,int>p[100001]; bool a[1001][1001]; int get(int f){ int cnt=0,c[2]={0}; for(int i=0;i<k;i++){ c[(p[i].fr/f+p[i].sc/f)%2]++; } int m=n/f; res=(m/2)*m+((m%2)*(m/2))-c[1]+c[0]; res=min(res,(m/2)*m+((m%2)*((m+1)/2))-c[0]+c[1]); return res; } /*void subtask2(){ int c[2]; c[0]=c[1]=0; for(i=0;i<k;i++){ scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc); p[i].fr--; p[i].sc--; c[(p[i].fr+p[i].sc)%2]++; } res=(n/2)*n+((n%2)*(n/2))-c[1]+c[0]; res=min(res,(n/2)*n+((n%2)*((n+1)/2))-c[0]+c[1]); printf("%lld",res); exit(0); }*/ main(){ scanf("%lld%lld",&n,&k); //if(n>1000)subtask2(); for(i=0;i<k;i++){ scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc); p[i].fr--; p[i].sc--; //a[p[i].fr][p[i].sc]=1; } res=get(1); for(j=2;j*j<=n;j++){ if(n%j==0){ res=min(res,get(j)); res=min(res,get(n/j)); } } printf("%lld",res); }

Compilation message (stderr)

chessboard.cpp: In function 'long long int get(long long int)':
chessboard.cpp:10:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt=0,c[2]={0};
         ^~~
chessboard.cpp: At global scope:
chessboard.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~
chessboard.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...