Submission #340278

#TimeUsernameProblemLanguageResultExecution timeMemory
340278scalesChessboard (IZhO18_chessboard)C++17
39 / 100
80 ms1900 KiB
#include <bits/stdc++.h> /*#ifndef LOCAL_RUN #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("avx2,tune=native") #endif*/ using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s; cin>>n; cin>>k; z=0; maxi=1000000000; vector<long long> a(k),b(k); for(i=0;i<k;i++) { cin>>a[i]; cin>>b[i]; cin>>x; cin>>y; a[i]--; b[i]--; } vector<long long> viv; for(i=2;i<n;i++) { if(n%i==0) { viv.push_back(i); } } viv.push_back(1); x=viv.size(); for(i=0;i<x;i++) { kol=0; w=viv[i]; //cout<<"w="<<w<<endl; for(j=0;j<k;j++) { //cout<<"a="<<a[j]<<" b="<<b[j]<<" "<<a[j]%(2*w)<<" "<<b[j]%(2*w)<<endl; if( ((a[j]%(2*w)<w) && (b[j]%(2*w)>=w)) ||((a[j]%(2*w)>=w) && (b[j]%(2*w)<w))) { kol++; } } v=(n*n)/(w*w); if(v%2==0) { f=n*n/2; s=n*n/2; } else { s=(n*n-w*w)/2; f=n*n-s; } kol=k-kol; //cout<<"kol="<<kol<<" f="<<f<<" s="<<s<<" maxi="; maxi=min({maxi,(f-kol+k-kol),(kol+s-k+kol)}); //cout<<maxi<<endl; } cout<<maxi<<endl; return 0; }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:15:16: warning: unused variable 't' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                ^
chessboard.cpp:15:22: warning: unused variable 'dno' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                      ^~~
chessboard.cpp:15:30: warning: variable 'z' set but not used [-Wunused-but-set-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                              ^
chessboard.cpp:15:34: warning: unused variable 'm' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                  ^
chessboard.cpp:15:40: warning: unused variable 'x1' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                        ^~
chessboard.cpp:15:43: warning: unused variable 'tip' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                           ^~~
chessboard.cpp:15:47: warning: unused variable 'g' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                               ^
chessboard.cpp:15:49: warning: unused variable 'p' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                 ^
chessboard.cpp:15:51: warning: unused variable 'l' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                   ^
chessboard.cpp:15:53: warning: unused variable 'r' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                     ^
chessboard.cpp:15:55: warning: unused variable 'sum' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                       ^~~
#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...