답안 #907413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
907413 2024-01-15T13:52:20 Z daoquanglinh2007 Chessboard (IZhO18_chessboard) C++17
8 / 100
15 ms 1372 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int NM = 1e5, inf = 1e18;

int N, K, x[NM+5], y[NM+5], ans = +inf;
int num[2];

void solve(int t){
	num[0] = num[1] = 0;
	for (int i = 1; i <= K; i++){
		int blx = x[i]/t+(x[i]%t > 0), bly = y[i]/t+(y[i]%t > 0);
		num[(blx+bly)%2]++;
	}
	int targ = t*t*(N*N/(t*t)/2);
	ans = min(ans, abs(targ-num[0])+num[1]);
	ans = min(ans, abs(targ-num[1])+num[0]);
	ans = min(ans, abs(N*N-targ-num[0])+num[1]);
	ans = min(ans, abs(N*N-targ-num[1])+num[0]);
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> K;
	for (int i = 1; i <= K; i++){
		cin >> x[i] >> y[i] >> x[i] >> y[i];
	}
	for (int i = 1; i*i <= N; i++)
		if (N%i == 0){
			solve(i);
			if (i > 1) solve(N/i);
		}
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 15 ms 1372 KB Output isn't correct
10 Halted 0 ms 0 KB -