답안 #91704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91704 2018-12-29T10:42:00 Z emil_physmath Chessboard (IZhO18_chessboard) C++14
0 / 100
26 ms 1272 KB
#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 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

chessboard.cpp: In function 'int FindAns(int, int)':
chessboard.cpp:25:36: warning: unused variable 'isBlack' [-Wunused-variable]
  int shouldWhite=0, shouldBlack=0, isBlack=0;
                                    ^~~~~~~
chessboard.cpp: In function 'int main()':
chessboard.cpp:15: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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -