# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91705 | emil_physmath | Chessboard (IZhO18_chessboard) | C++14 | 2063 ms | 1272 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 <iostream>
#include <stdio.h>
using namespace std;
const int MAXK=100005;
int mini[MAXK], maxi[MAXK], minj[MAXK], maxj[MAXK];
int IsWhite(int, int);
int FindAns(int n, int k);
int main()
{
int n, k;
cin>>n>>k;
for (int i=0; i<k; i++)
scanf("%d%d%d%d", mini+i, minj+i, maxi+i, maxj+i);
cout<<FindAns(n, k)<<'\n';
char I;
cin >> I;
return 0;
}
int FindAns(int n, int k)
{
int ans=0;
for (int x=1; x<=n; x++)
for (int y=1; y<=n; y++)
{
bool isBlack=false;
for (int i=0; i<k; i++)
if (mini[i]==x && minj[i]==y)
{
isBlack=true;
break;
}
if (isBlack)
{
if (IsWhite(x, y))
ans++;
}
else
{
if (!IsWhite(x, y))
ans++;
}
}
return min(ans, n*n-ans);
//int shouldWhite=0, shouldBlack=0, isBlack=0;
//for (int i=0; i<k; i++)
// if (IsWhite(maxi[i], maxj[i]))
// shouldWhite++;
//shouldBlack=((n*n)/2)-(k-shouldWhite);
//return min(shouldWhite+shouldBlack, n*n-(shouldWhite+shouldBlack));
}
int IsWhite(int i, int j)
{
return ((i+j)%2==0);
}
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... |