| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 684239 | mychecksedad | Chessboard (IZhO18_chessboard) | C++17 | 1539 ms | 6464 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define all(x) x.begin() x.end()
#define MOD (1e9+7)
const int N = 1e6;
ll n, k, ans = 1e18;
vector<array<ll, 4>> vv;
ll wh(ll x, ll y, ll d){
x++, y++;
if(x <= 0 || y <= 0) return 0;
ll xd = x / d;
ll yd = y / d;
ll res = (xd * yd >> 1) * d * d;
if(x % (2*d) >= d){
ll y1 = (yd >> 1) * 2 * d;
res += (yd >> 1) * (x % d) * d;
res += (x % d) * min(d, y % (2*d));
}else{
ll y1 = (yd >> 1) * 2 * d;
res += (yd >> 1) * (x % d) * d;
}
if(y % (2*d) >= d){
ll x1 = (xd >> 1) * 2*d;
res += (xd >> 1) * (y % d) * d;
res += (y % d) * min(d, x % (2*d));
}else{
ll x1 = (xd >> 1) * 2*d;
res += x1 / (2*d) * (y % d) * d;
}
return res;
}
void solve(){
cin >> n >> k;
int a = 0;
for(int i = 0; i < k; ++i){
int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
vv.pb({x1-1,y1-1,x2-1,y2-1});
}
for(ll i = 1; i < n; ++i){
if(n % i == 0){
ll c = 0;
for(auto v: vv){
ll white = wh(v[2], v[3], i) - wh(v[0] - 1, v[3], i) - wh(v[2], v[1] - 1, i) + wh(v[0] - 1, v[1] - 1, i);
ll black = (v[2] + 1) * (v[3] + 1) - (v[0]) * (v[3] + 1) - (v[2] + 1) * (v[1]) + (v[0] * v[1]) - white;
ll val = white - black;
c += val;
}
ans = min(ans, c + ((n/i)*(n/i) + 1)/2*i*i);
ans = min(ans, - c + (n/i)*(n/i)/2*i*i);
}
}
cout << ans;
}
int main(){
solve();
return 0;
}컴파일 시 표준 에러 (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... | ||||
