# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
880804 | dimashhh | Chessboard (IZhO18_chessboard) | C++17 | 804 ms | 162756 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>
using namespace std;
typedef long long ll;
const int N = 1e5 + 1;
#define int long long
int odd[N][101],even[N][101],it = 0;
ll col_eq(int k,int x,int y,int x1,int y1){
ll ret = (odd[x1][k] - odd[x - 1][k]) * (odd[y1][k] - odd[y - 1][k]);
ret += (even[x1][k] - even[x - 1][k]) *1ll* (even[y1][k] - even[y - 1][k]);
return ret;
}
ll col_non_eq(int k,int x,int y,int x1,int y1){
return (x1 - x + 1) *1ll* (y1 - y + 1) - col_eq(k,x,y,x1,y1);
}
vector<pair<pair<int,int>,pair<int,int>>> a;
ll n,k;
int get(ll del,ll i){
ll res1 = 0,res2 = 0;
for(auto [x,y]:a){
res1 += col_eq(i,x.first,x.second,y.first,y.second);
res2 += col_non_eq(i,x.first,x.second,y.first,y.second);
}
ll x = res1;
res1 = ((n * n / del / del) + 1) / 2 * (del * del) - res1 + res2;
res2 = ((n * n / del / del)) / 2 * (del * del) + x - res2;
// cout << ((n * n / del / del) + 1) / 2 * del * del - res2 << '\n';
return min(res1,n * n - res1);
}
void test(){
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... |