답안 #488347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
488347 2021-11-18T16:54:43 Z levsog2004 Chessboard (IZhO18_chessboard) C++14
8 / 100
18 ms 976 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef  int  ll;
#define all(x) x.begin(),x.end()
#define al(a,n)  (a,a+n)
#define se second
#define fr first
#define m_p make_pair
const ll N = 1005;
const ll mod = 1000 * 1000 * 1000 + 7;
const ll inf = 1000000009;
ll n, m, k, z, t, x, y, ans, pat,a[N][N];
pair<ll, ll> p[N][N];
vector<pair<ll, ll>> v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> x >> y >> x >> y;
		v.push_back({ x,y });
	}
	ans = inf;
	for (int ii = 1; ii < n; ++ii)
	{
		x = 0;
		y = 0;
		if (n % ii == 0)
		{
			for (int i = 0; i < m; ++i)
			{
				if ((v[i].first / ii + v[i].second / ii) % 2 == 0)
				{
					x++;
				}
				else
					y++;
			}
			k = n / ii;
			k *= k;
			z = k / 2;
			if (k % 2 == 1)
				z++;
			k /= 2;
			ans = min(ans, min(z*ii*ii-x+y,k*ii*ii-y+x));
		}
	}
	cout << ans << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 18 ms 976 KB Output isn't correct
10 Halted 0 ms 0 KB -