Submission #818842

#TimeUsernameProblemLanguageResultExecution timeMemory
818842tengiz05Cell Automaton (JOI23_cell)C++17
8 / 100
8053 ms1116 KiB
#include <bits/stdc++.h> using i64 = long long; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<int> x(n), y(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } while (q--) { i64 k; cin >> k; sort(x.begin(), x.end()); auto calc = [&](i64 k) { if (k % 2 == 0) { i64 ans = 0; for (int i = 0; i < n; i++) { ans += (k + 1) * (k + 1) + k * k; if (i + 1 < n && x[i + 1] - x[i] <= k) { i64 f = k - (x[i + 1] - x[i]) + 1; ans -= f * (k + 1); ans -= (f - 1) * k; } } return ans; } else { i64 ans = 0; for (int i = 0; i < n; i++) { ans += (k + 1) * (k + 1) + k * k; if (i + 1 < n && x[i + 1] - x[i] <= k) { i64 f = k - (x[i + 1] - x[i]) + 1; ans -= f * (k + 1); ans -= (f - 1) * k; } } return ans; } }; if (k == 0) cout << n << "\n"; else { cout << calc(k) - calc(k - 1) << "\n"; } } return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...