Submission #855846

#TimeUsernameProblemLanguageResultExecution timeMemory
855846Trisanu_DasChessboard (IZhO18_chessboard)C++17
0 / 100
48 ms4440 KiB
#include <iostream> #include <algorithm> #include <climits> #define int long long using namespace std; int f(int s, int a) { a %= s * 2; return min(a, s * 2 - a); } signed main() { int n, k, temp, ans; cin >> n >> k; int x1[n], y1[n], x2[n], y2[n]; for (int i = 0; i < k; i++){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; --x1[i]; --y1[i]; } ans = LLONG_MAX; for (int i = 1; i < n; i++) if (n % i == 0) { k = (n / i) * (n / i) / 2 * i * i; for (int j = 0; j < k; j++) temp += (f(i, x2[j]) - f(i, x1[j])) * (f(i, y2[j]) - f(i, y1[j])); ans = min(ans, min(temp, n * n - temp)); } cout << ans << '\n'; }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:24:37: warning: 'temp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |    for (int j = 0; j < k; j++) temp += (f(i, x2[j]) - f(i, x1[j])) * (f(i, y2[j]) - f(i, y1[j]));
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...