Submission #334337

#TimeUsernameProblemLanguageResultExecution timeMemory
334337beksultan04Chessboard (IZhO18_chessboard)C++14
0 / 100
37 ms3968 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define endi puts(""); const int N = 1e5+12,INF=1e9+7; int resh[N],ans[N],n; vector <int> v[N]; int fun(int x){ int i,j,ans=0,cnt=0,res=(n*n+1)/2,c=1; for (i=1;i<=n;++i){ for (j=0;j<v[i].size();++j){ int y = v[i][j]/x; if (y%2 == 0 && c%2 == 1 || y%2 == 1 && c%2 == 0 )res--; else res++; } cnt++; if (cnt % x == 0) c++; } ret min((res),n*n-res); } main(){ int k,i,j; vector <int> pr; scan2(n,k) while (k--){ int x1,x2,y1,y2; scan2(x1,y1) scan2(x2,y2) v[x1].pb(y1); } /// /////////////////////// for (i=2;i*i<=n;++i){ if (n%i==0){ pr.pb(i); if (i*i != n)pr.pb(n/i); } } int ans=fun(1); for (i=0;i<pr.size();++i){ ans = min(ans,fun(pr[i])); } cout <<ans; }

Compilation message (stderr)

chessboard.cpp: In function 'long long int fun(long long int)':
chessboard.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (j=0;j<v[i].size();++j){
      |                  ~^~~~~~~~~~~~
chessboard.cpp:23:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |             if (y%2 == 0 && c%2 == 1 || y%2 == 1 && c%2 == 0 )res--;
      |                 ~~~~~~~~~^~~~~~~~~~~
chessboard.cpp:19:13: warning: unused variable 'ans' [-Wunused-variable]
   19 |     int i,j,ans=0,cnt=0,res=(n*n+1)/2,c=1;
      |             ^~~
chessboard.cpp: At global scope:
chessboard.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main(){
      |      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:53:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (i=0;i<pr.size();++i){
      |              ~^~~~~~~~~~
chessboard.cpp:35:13: warning: unused variable 'j' [-Wunused-variable]
   35 |     int k,i,j;
      |             ^
chessboard.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:37:5: note: in expansion of macro 'scan2'
   37 |     scan2(n,k)
      |     ^~~~~
chessboard.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:41:9: note: in expansion of macro 'scan2'
   41 |         scan2(x1,y1)
      |         ^~~~~
chessboard.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:42:9: note: in expansion of macro 'scan2'
   42 |         scan2(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...