Submission #1149346

#TimeUsernameProblemLanguageResultExecution timeMemory
1149346aktilekChessboard (IZhO18_chessboard)C++20
16 / 100
16 ms528 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define Fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N = 2e5 + 7; const int R = 1e9 + 10; const ll INF = 1e18; const ll MOD = 1e9 + 7; const int B = 320; void solve() { int n, k; cin >> n >> k; if (n <= 100 && k == 0) { int ans = R; for (int i = 1; i < n; i++) { if (n % i == 0) { if ((n / i) % 2 == 0) { ans = min(ans, n / (i + i) * n * i * i); // cout << "1 " << ans << "\n"; } else { int sum = 0; for (int j = 2; j <= n / i; j += 2) { sum += j; } sum *= 2; ans = min(ans, sum * i * i); // cout << "2 " << ans << ' ' << sum << "\n"; } // cout << i << '\n'; } } cout << ans << '\n'; } else { ll a = 0, b = 0; for (int i = 1; i <= k; i++) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if ((x1 + y1) % 2 == 0) { a++; } else { b++; } } ll needa = 0, needb = 0; for (int i = 1; i <= n; i++) { if (i % 2 == 0) { needb += i; } else { needa += i; } } needa *= 2; needb *= 2; needa -= n; // cout << needa << ' ' << needb << '\n'; cout << min(needa - a + b, needb - b + a) << '\n'; } } int main() { // freopen("gates.in", "r", stdin); // freopen("gates.out", "w", stdout); Fast int tc = 1; // cin >> tc; while (tc--) { solve(); } }
#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...