# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
76739 | Good | Chessboard (IZhO18_chessboard) | C++11 | 2055 ms | 63724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define Maxn 100009
#define ll long long
#define pb push_back
#define Inf 1000000009
#define ppb() pop_back()
#define pii pair <int , int>
#define mid(x, y) (x + y) / 2
#define all(x) x.begin(),x.end()
#define llInf 1000000000000000009
#define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++)
using namespace std;
using namespace __gnu_pbds;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order;
int n, k;
pii x[Maxn];
pii y[Maxn];
ll ans = llInf;
vector <int> A;
int main () {
//freopen ("file.in", "r", stdin);
//freopen ("file.out", "w", stdout);
//srand ((unsigned) time ( NULL ));
//int randomNumber = rand() % 10 + 1;
scanf ("%d%d", &n, &k);
for (int i = 1; i <= k; i++)
scanf ("%d%d%d%d", &x[i].ff, &y[i].ff, &x[i].ss, &y[i].ss);
for (int i = 1; i < n; i++)
if (!(n % i))
A.pb (i);
if (k == 0) {
for (auto i: A) {
ll v = i;
ll u = n / i;
u = ((u * u) / 2) * v * v;
ans = min (ans, u);
}
return printf ("%lld\n", ans), 0;
}
for (int i = 0; i < 2; i++) {
for (auto j: A) {
ll v = j;
ll u = n / j;
if (i)
u = ((u * u) / 2) * v * v;
else
u = ((u * u) - (u * u) / 2) * v * v;
for (int l = 1; l <= k; l++) {
for (int p = x[l].ff; p <= x[l].ss; p++)
for (int e = y[l].ff; e <= y[l].ss; e++) {
int a = (p - 1) / j;
int b = (e - 1) / j;
bool q = 0;
if (!(a & 1) and b & 1) q = 1;
if (a & 1 and !(b & 1)) q = 1;
if (i)
q = !q;
if (q) u++;
else u --;
}
}
ans = min (ans, u);
}
}
printf ("%lld\n", ans);
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... |