Submission #172814

#TimeUsernameProblemLanguageResultExecution timeMemory
172814muhammad_hokimiyonChessboard (IZhO18_chessboard)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define fi first #define se second #define ll long long using namespace std; const int N = 1e5 + 7; const int M = 23; const int mod = 998244353; ll n,k; ll A[N]; ll B[N]; ll C[N]; ll D[N]; ll x1, y1, a, b; ll f( ll x , ll y , ll &div ) { x1 = y / div; y1 = x / div; x1 = x1 * y1 + 1; x1 /= 2; x1 *= div * div; a = y % div; b = x % div; if( ((y - 1) / div % 2 == 0 && div > 1) ){ x1 += ((x / div + 1) / 2) * div * a; }else{ x1 += x / div / 2 * div * a; } if( ((x - 1) / div % 2 == 0) ){ x1 += (y / div + 1) / 2 * div * b; }else{ x1 += y / div / 2 * div * b; } if( ((x - 1) / div % 2 == 1 && (y - 1) / div % 2 == 1) || ((x - 1) / div % 2 == 0 && (y - 1) / div % 2 == 0) ){ x1 += (x % div) * (y % div); } //cout << x << " " << y << " " << div << " " << x1 << " " << fg[x][y] << "\n"; return x1; } void solve1() { cin >> n >> k; vector < ll > div; for( int i = 1; i < n; i++ ){ if( n % i == 0 )div.push_back(i); } for( int i = 0; i < k; i++ ){ cin >> A[i] >> B[i] >> C[i] >> D[i]; } ll ans = 1e14; for( int i = 0; i < (int)div.size(); i++ ){ ll nn = n / div[i]; ll fg = div[i] * div[i]; ll B1 = (nn + 1) / 2; ll B2 = nn / 2; B1 *= fg; B2 *= fg; B1 *= (nn + 1) / 2; B2 *= nn / 2; B1 += B2; ll B3 = (nn) / 2; ll B4 = (nn + 1) / 2; B3 *= fg; B4 *= fg; B3 *= (nn + 1) / 2; B4 *= (nn) / 2; B3 += B4; vector < ll > w(k , 0); vector < ll > b(k , 0); ll x, y; for( int j = 0; j < k; j++ ){ x = f(C[j] , D[j] , div[i]) - f(C[j] , B[j] - 1 , div[i]) - f(A[j] - 1, D[j] , div[i]) + f(A[j] - 1 , B[j] - 1 , div[i]); y = (C[j] - A[j] + 1) * (D[j] - B[j] + 1); w[j] = y - x; b[j] = x; } x = 0; y = 0; //cout << B1 << " " << B3 << "\n"; for( int j = 0; j < k; j++ ){ B1 -= b[j]; x += w[j]; y += b[j]; B3 -= w[j]; //if( div[i] == 1 )cout << b[j] << " "; } //cout << "\n"; //cout << B1 + x << " " << B3 + y << " " << div[i] << "\n"; ans = min(ans , B1 + x); ans = min(ans , B3 + y); } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen( "input.txt" , "r" , stdin ); //freopen( "output.txt" , "w" , stdout ); int cghf = 1;//cin >> cghf; while( cghf-- ){ solve1(); } }

Compilation message (stderr)

chessboard.cpp:20:8: error: 'long long int y1' redeclared as different kind of symbol
 ll x1, y1, a, b;
        ^~
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from chessboard.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:251:1: note: previous declaration 'double y1(double)'
 __MATHCALL (y1,, (_Mdouble_));
 ^
chessboard.cpp: In function 'long long int f(long long int, long long int, long long int&)':
chessboard.cpp:25:14: error: assignment of function 'double y1(double)'
     y1 = x / div;
              ^~~
chessboard.cpp:25:14: error: cannot convert 'long long int' to 'double(double) throw ()' in assignment
chessboard.cpp:26:13: error: invalid operands of types 'long long int' and 'double(double) throw ()' to binary 'operator*'
     x1 = x1 * y1 + 1;
          ~~~^~~~