Submission #91703

#TimeUsernameProblemLanguageResultExecution timeMemory
91703emil_physmathChessboard (IZhO18_chessboard)C++14
0 / 100
26 ms1144 KiB
#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 len; //cin>>len; //while (true) //{ // int mini, minj, maxi, maxj; // cin>>mini>>minj>>maxi>>maxj; // cout<<"There are "<<NumWhite(mini, minj, maxi, maxj, len) // <<" white cells in that subrectangle.\n"; // int realAns=0; // for (int i=mini; i<=maxi; i++) // for (int j=minj; j<=maxj; j++) // if (((i+len-1)/len+(j+len-1)/len)%2==0) // realAns++; // if (NumWhite(mini, minj, maxi, maxj, len)==realAns) // cout<<"OK\n"; // else // cout<<"\aWA\n Should be "<<realAns<<".\n"; // cout<<endl; //} 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 shouldWhite=0, shouldBlack=0, isBlack=0; for (int i=0; i<k; i++) { if (IsWhite(maxi[i], maxj[i])) shouldWhite++; isBlack++; } shouldBlack=((n*n)/2)-(isBlack-shouldWhite); return min(shouldWhite+shouldBlack, n*n-(shouldWhite+shouldBlack)); } int IsWhite(int i, int j) { return ((i+j)%2==0); }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d%d", mini+i, minj+i, maxi+i, maxj+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...