Submission #68093

# Submission time Handle Problem Language Result Execution time Memory
68093 2018-08-15T22:00:54 Z MatheusLealV Chessboard (IZhO18_chessboard) C++17
0 / 100
34 ms 1440 KB
#include <bits/stdc++.h>
#define N 100050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int n, k, x[N], y[N], xf[N], yf[N];

long long ans = (2000000000000000000ll);

vector<int> d;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>k;

	for(int i = 1; i <= k; i++) cin>>x[i]>>y[i]>>xf[i]>>yf[i];

	for(int i = 1; i <= k; i++) x[i] --, y[i] --, xf[i] --, yf[i] --;

	for(int i = 1; i <= sqrt(n); i++)
	{
		if((n % i) != 0) continue;

		d.push_back(i);

		if(i != n/i) d.push_back(n/i);
	}

	for(auto r: d)
	{	
		ll pretocerto = 0, pretoerrado = 0, tot;

		tot = ( (n/r) * (n/r) + 1)/2;

		tot = (tot * r * r); 

		//if(r != 2) continue;

		for(int i = 1; i <= k; i++)
		{
			int linha = (x[i] % (2*r) < r ? 1 : 0), coluna = (y[i] % (2*r) < r ? 1 : 0);

			if(!linha) coluna = !coluna;

			//cout<<x[i]<<" "<<y[i]<<" COR = "<<linha<<" "<<coluna<<"\n";

			if(!coluna) pretoerrado ++;

			else pretocerto ++;
		}

		//cout<<custo<<" "<<branco<<"\n";

		ans = min(ans, tot - pretocerto + pretoerrado);
	}

	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 1440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 1440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -