Submission #151526

# Submission time Handle Problem Language Result Execution time Memory
151526 2019-09-03T13:44:07 Z nvmdava Chessboard (IZhO18_chessboard) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
vector<ll> di = {1};
ll dif[200005], res = 1e12;
 
inline get(ll x, ll d){
	return x / (2 * d) * d + min(x % (2 * d), d);
}
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	ll n, k, ox, ex, oy, ey;
	cin>>n>>k;
	for(ll i = 2; i * i <= n; i++){
		if(n % i == 0){
			di.push_back(i);
			if(i * i != n) di.push_back(n / i);
		}
	}
	
	for(ll i = 0; i < di.size(); i++)
		dif[i] = n * n - n * n / (di[i] * di[i]) / 2 * (di[i] * di[i]);
	
	while(k--){
		ll x1, x2, y1, y2;
		cin>>x1>>y1>>x2>>y2;
 		x1--; y1--;
		for(ll i = 0; i < di.size(); i++){
			ex = get(x2, di[i]) - get(x1, di[i]);
			ox = x2 - x1 - ex;
			ey = get(y2, di[i]) - get(y1, di[i]);
			oy = y2 - y1 - ey;
			dif[i] += ex * oy + ey * ox - ex * ey - ox * oy;
		}
	}
 
	for(ll i = 0; i < di.size(); i++)
		res = min(res, min(dif[i], n * n - dif[i]));
	
	cout<<res;
}

Compilation message

chessboard.cpp:8:22: error: ISO C++ forbids declaration of 'get' with no type [-fpermissive]
 inline get(ll x, ll d){
                      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:26:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i = 0; i < di.size(); i++)
                ~~^~~~~~~~~~~
chessboard.cpp:33:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll i = 0; i < di.size(); i++){
                 ~~^~~~~~~~~~~
chessboard.cpp:42:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i = 0; i < di.size(); i++)
                ~~^~~~~~~~~~~