# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
133419 | Kastanda | Chessboard (IZhO18_chessboard) | C++11 | 228 ms | 5084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// ItnoE
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N = 100005;
int n, k, dp[N], dp2[N];
pair < int , int > A[N], B[N];
inline long long Solve(int d)
{
long long tot = n / d;
tot *= tot; tot = (tot + 1) >> 1;
tot *= 1LL * d * d;
for (int i = 1; i <= n; i ++)
dp[i] = dp[i - 1] + ((i - 1) / d % 2 == 0), dp2[i] = i - dp[i];
for (int i = 0; i < k; i ++)
{
int ax = dp[B[i].first] - dp[A[i].first];
int bx = dp2[B[i].first] - dp2[A[i].first];
int ay = dp[B[i].second] - dp[A[i].second];
int by = dp2[B[i].second] - dp2[A[i].second];
tot -= 1LL * ax * ay;
tot -= 1LL * bx * by;
tot += 1LL * ax * by;
tot += 1LL * bx * ay;
}
return (min(tot, 1LL * n * n - tot));
}
int main()
{
scanf("%d%d", &n, &k);
for (int i = 0; i < k; i ++)
scanf("%d%d%d%d", &A[i].x, &A[i].y, &B[i].x, &B[i].y), A[i].x --, A[i].y --;
long long Mn = LLONG_MAX;
for (int d = 1; d < n; d ++)
if (n % d == 0)
Mn = min(Mn, Solve(d));
return !printf("%lld\n", Mn);
}
컴파일 시 표준 에러 (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... |