# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523568 | RaresFelix | Chessboard (IZhO18_chessboard) | C++17 | 483 ms | 2544 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define MN 107171
using namespace std;
using ll = long long;
int n, k;
vector<tuple<int, int, int, int>> R;
ll calc(ll a, ll b, ll l) {
if(a % l == 0 && b % l == 0)
return ((a / l) * (b / l) + 1) / 2 * l * l;
if(a % l) {
ll nrseg;
if(a / l % 2ll == 0) {
if(b % (2ll * l) <= l) nrseg = (b / (2ll * l)) * l + b % (2 * l);
else nrseg = (b / (2ll * l) + 1) * l;
} else {
if(b % (2ll * l) <= l) nrseg = (b / (2ll * l)) * l;
else nrseg = (b / (2ll * l) - 1) * l + b % (2 * l);
}
return calc(a - (a % l), b, l) + (a % l) * nrseg;
}
return calc(b, a, l);
}
ll sol(int l) {
ll arie = ((n / l) * (n / l) + 1) / 2 * l * l, selec, hash;
for(auto [a, b, c, d] : R) {
selec = calc(c, d, l) + calc(a-1, b-1, l) - calc(c, b-1, l) - calc(a-1, d, l);
arie += (c - a + 1) * (d - b + 1) - 2 * selec;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |