Submission #378562

#TimeUsernameProblemLanguageResultExecution timeMemory
378562ElaineHuangChessboard (IZhO18_chessboard)C++14
47 / 100
76 ms748 KiB
#include<bits/stdc++.h> #define debug 0 #define int long long #define min trash using namespace std; int b[10005][2];//black squares //vector<int> factor; int factor[10005],fs;//factor size int N; int Min(int a,int b) { return a<b?a:b; } int p(int f) { int o=((N/f)*(N/f)/2)*f*f;//o->odd blocks int e=N*N-o;//e->even blocks if(debug) printf("f%d o%d e%d\n",f,o,e);// return Min(b[f][1]+e-b[f][0],b[f][0]+o-b[f][1]);//e黑//o黑 } signed main() { int K,x1,x2,y1,y2; scanf("%lld %lld",&N,&K); int g=(int)sqrt(N); //factor.clear(); memset(b,0,sizeof(b)); for(int i=1;i<=g;i++) { if(!(N%i)) { factor[fs]=i; fs++; } if(debug) printf("i=%d\n",i);// } if(debug) printf("%d, g%d\n",fs,g);// while(K--) { scanf("%lld %lld %lld %lld",&x1,&y1,&x2,&y2); x1--,y1--,x2--,y2--; for(int i=0;i<fs;i++) { int a;//determine 0 or 1 int f;//factor f=factor[i]; a=x1/f+y1/f; a%=2; b[f][a]++; if(f==N/f) break; if(f==1) continue; f=N/factor[i]; a=x1/f+y1/f; a%=2; b[f][a]++; } } int ans=N*N; for(int i=0;i<fs;i++) { int f; f=factor[i];//p->paint幾格 ans=Min(p(f),ans); if(f==N/f) break; if(f==1) continue; f=N/f; ans=Min(p(f),ans); } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

chessboard.cpp: In function 'long long int p(long long int)':
chessboard.cpp:18:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   18 |  if(debug) printf("f%d o%d e%d\n",f,o,e);//
      |                     ~^            ~
      |                      |            |
      |                      int          long long int
      |                     %lld
chessboard.cpp:18:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
   18 |  if(debug) printf("f%d o%d e%d\n",f,o,e);//
      |                         ~^          ~
      |                          |          |
      |                          int        long long int
      |                         %lld
chessboard.cpp:18:30: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long long int' [-Wformat=]
   18 |  if(debug) printf("f%d o%d e%d\n",f,o,e);//
      |                             ~^        ~
      |                              |        |
      |                              int      long long int
      |                             %lld
chessboard.cpp: In function 'int main()':
chessboard.cpp:35:24: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   35 |   if(debug) printf("i=%d\n",i);//
      |                       ~^    ~
      |                        |    |
      |                        int  long long int
      |                       %lld
chessboard.cpp:37:21: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   37 |  if(debug) printf("%d, g%d\n",fs,g);//
      |                    ~^         ~~
      |                     |         |
      |                     int       long long int
      |                    %lld
chessboard.cpp:37:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
   37 |  if(debug) printf("%d, g%d\n",fs,g);//
      |                         ~^       ~
      |                          |       |
      |                          int     long long int
      |                         %lld
chessboard.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |  scanf("%lld %lld",&N,&K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
chessboard.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |   scanf("%lld %lld %lld %lld",&x1,&y1,&x2,&y2);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...