Submission #1107763

# Submission time Handle Problem Language Result Execution time Memory
1107763 2024-11-02T04:59:18 Z stdfloat Gift (IZhO18_nicegift) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define ff	first
#define ss	second
#define pii	pair<int, int>

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

	int n, k;
	cin >> n >> k;

	pii p1[k], p2[k];
	for (int i = 0; i < k; i++) {
		cin >> p1[i].ff >> p1[i].ss >> p2[i].ff >> p2[i].ss;
		p1[i].ff--; p1[i].ss--; p2[i].ff--; p2[i].ss--;
	}

	ll ans = LLONG_MAX;
	for (int ii = 1; ii * ii <= n; ii++) {
		if (n % ii) continue;

		for (auto i : {ii, n / ii}) {
			if (i == n) continue;

			int x = n / i;
			ll cnt1 = ((ll)((x + 1) >> 1) * ((x + 1) >> 1) + (ll)(x >> 1) * (x >> 1)) * i * i, cnt2 = ((ll)((x + 1) >> 1) * (x >> 1) + (ll)(x >> 1) * ((x + 1) >> 1)) * i * i;
			
			for (int j = 0; j < k; j++) {
				if (((p1[j].ff / i) & 1) == ((p1[j].ss / i) & 1)) {
					cnt1--; cnt2++;
				}
				else {
					cnt1++; cnt2--;
				}
			}
		
			ans = min({ans, cnt1, cnt2});
		}
	}

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Expected int32, but "480000000000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -