Submission #855851

#TimeUsernameProblemLanguageResultExecution timeMemory
855851Trisanu_DasChessboard (IZhO18_chessboard)C++17
100 / 100
347 ms5904 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n, k; cin >> n >> k; int ans = n * n; array<int, 4> a[k]; for(auto &[i, j, k, l] : a) cin >> i >> j >> k >> l; for(int m = 1; m < n; m++) if(!(n % m)) { #define c(V) (m * ((V) / (2 * m)) + min(m, (V) % (2 * m))) int t = c(n) * (n - c(n)) + c(n) * (n - c(n)); for(auto [i, j, k, l] : a) { int u = k - i + 1, x = c(k) - c(i - 1); int v = l - j + 1, y = c(l) - c(j - 1); t += 2 * (x * y + (u - x) * (v - y)) - u * v; } ans = min(ans, min(t, n * n - t)); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...