답안 #68094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68094 2018-08-15T22:06:25 Z MatheusLealV Chessboard (IZhO18_chessboard) C++17
0 / 100
35 ms 2480 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;

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

long long ans = (2000000000000000000ll);

vector<ll> 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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 2480 KB Output is correct
2 Incorrect 11 ms 2480 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 2480 KB Output is correct
2 Incorrect 11 ms 2480 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -