Submission #77049

#TimeUsernameProblemLanguageResultExecution timeMemory
77049antimirageChessboard (IZhO18_chessboard)C++17
0 / 100
35 ms1312 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k, x[2][N], y[2][N]; long long ans = 1e18; long long calc (int i) { long long res = 0; for (int j = 1; j <= k; j++) { if ((x[0][j] / i + y[0][j] / i) & 1) res++; } return min( res + (n * 1ll * n + 1) / 2 - (k - res), (k - res) + (n * 1ll * n) / 2 - res); } int main() { cin >> n >> k; for (int i = 1; i <= k; i++) { scanf("%d%d", &x[0][i], &y[0][i]), x[0][i]--, y[0][i]--; scanf("%d%d", &x[1][i], &y[1][i]), x[1][i]--, y[1][i]--; } for (int i = 1; i * i <= n; i++) { if (n % i != 0) continue; ans = min(ans, calc(i) ); ans = min(ans, calc(n / i) ); } cout << ans << endl; } /** 6 8 3 3 3 3 1 2 1 2 3 4 3 4 5 5 5 5 4 3 4 3 4 4 4 4 2 1 2 1 3 6 3 6 4 1 4 1 4 4 **/

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:29:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x[0][i], &y[0][i]), x[0][i]--, y[0][i]--;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
chessboard.cpp:30:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x[1][i], &y[1][i]), x[1][i]--, y[1][i]--;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#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...