Submission #1108412

# Submission time Handle Problem Language Result Execution time Memory
1108412 2024-11-04T04:49:58 Z Muhammet Chessboard (IZhO18_chessboard) C++17
8 / 100
16 ms 2896 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

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

	ll n, k;
	cin >> n >> k;
	vector <int> x1(k+1), y1(k+1), x2(k+1), y2(k+1);
	for(int i = 1; i <= k; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	ll ans = n*n;
	for(int x3 = 1; x3 < n; x3++){
		if(n % x3 != 0) continue;
		int x = (x3 * 2), cnt1 = 0, cnt2 = 0;
		for(int i = 1; i <= k; i++){
			if((x1[i] % x) <= (x / 2) and (x1[i] % x) != 0){
				if((y1[i] % x) <= (x / 2) and (y1[i] % x) != 0) cnt1++;
				else cnt2++;
			}
			else {
				if((y1[i] % x) <= (x / 2) and (y1[i] % x) != 0) cnt2++;
				else cnt1++;
			}
		}
		ll y = ((x3 * x3) * (((n / x3) + 1) / 2) * (((n / x3) + 1) / 2)) + ((x3 * x3) * ((n / x3) / 2) * ((n / x3) / 2));
		ans = min(ans, (y - cnt1 + (k-cnt2)));
		ans = min(ans, (n*n - y) - cnt2 + (k-cnt1));
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Incorrect 16 ms 2896 KB Output isn't correct
10 Halted 0 ms 0 KB -