# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91830 | emil_physmath | Chessboard (IZhO18_chessboard) | C++14 | 27 ms | 2300 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>
#include <set>
using namespace std;
const long long MAXK=100005;
long long mini[MAXK], maxi[MAXK], minj[MAXK], maxj[MAXK];
bool IsWhite(long long, long long);
long long FindAns(long long n, long long k);
int main()
{
long long n, k;
cin>>n>>k;
for (long long i=0; i<k; i++)
scanf("%lld%lld%lld%lld", mini+i, minj+i, maxi+i, maxj+i);
cout<<FindAns(n, k)<<'\n';
char I;
cin >> I;
return 0;
}
long long FindAns(long long n, long long k)
{
long long shouldWhite=0, shouldBlack=(n*n)/2;
for (long long i=0; i<k; i++)
{
if (IsWhite(maxi[i], maxj[i]))
shouldWhite++;
else
shouldBlack--;
}
return min(1LL+shouldWhite+shouldBlack, n*n-(shouldWhite+shouldBlack));
}
bool IsWhite(long long i, long long 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... |