답안 #76769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76769 2018-09-17T16:13:34 Z zetapi Chessboard (IZhO18_chessboard) C++14
70 / 100
702 ms 2300 KB
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define int long long
#define itr iterator

typedef pair<int,int> pii;

const int MAX=1e6;
const int INF=1e12;

pii arr[MAX];

int N,K,ans;

int cell(int a,int c)
{
	return (a-1)/c+1;
}

int cell(int a,int b,int c)
{
	a--;
	b--;
	a/=c;
	b/=c;
	a++;
	b++;
	return a+b;
}

int cal(int X)
{
	if(X==N)
		return INF;
	//At first color the cell (1,1) white
	int res=(((N/X)*(N/X))/2)*X*X;
	for(int A=1;A<=K;A++)
	{
		if(cell(arr[A].first,arr[A].second,X)%2==0)	//this cell should be white
			res++;
		else	//this cell should be black
			res--;
	}
	//Color the cell (1,1) black
	int res_2=(((N/X)*(N/X))/2+(N/X)%2)*X*X;
	for(int A=1;A<=K;A++)
	{
		if(cell(arr[A].first,arr[A].second,X)%2==0)	//this cell should be black
			res_2--;
		else
			res_2++;
	}
	return min(res,res_2);
}

signed main()
{
	ios_base::sync_with_stdio(false);

	ans=INF;
	cin>>N>>K;
	for(int A=1;A<=K;A++)
		cin>>arr[A].first>>arr[A].second>>arr[A].first>>arr[A].second;
	for(int A=1;A*A<=N;A++)
	{
		if(!(N%A))
		{
			if(A*A==N)
				ans=min(ans,cal(A));
			else
				ans=min(ans,cal(A)),
				ans=min(ans,cal(N/A));
		}
	}
	cout<<ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 676 KB Output is correct
6 Correct 2 ms 676 KB Output is correct
7 Correct 2 ms 676 KB Output is correct
8 Correct 2 ms 676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1504 KB Output is correct
2 Correct 10 ms 1504 KB Output is correct
3 Correct 37 ms 1504 KB Output is correct
4 Correct 25 ms 1504 KB Output is correct
5 Correct 30 ms 1504 KB Output is correct
6 Correct 19 ms 1504 KB Output is correct
7 Correct 5 ms 1504 KB Output is correct
8 Correct 19 ms 1504 KB Output is correct
9 Correct 48 ms 2044 KB Output is correct
10 Correct 28 ms 2044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2044 KB Output is correct
2 Correct 2 ms 2044 KB Output is correct
3 Correct 3 ms 2044 KB Output is correct
4 Correct 3 ms 2044 KB Output is correct
5 Correct 2 ms 2044 KB Output is correct
6 Correct 2 ms 2044 KB Output is correct
7 Correct 3 ms 2044 KB Output is correct
8 Correct 2 ms 2044 KB Output is correct
9 Correct 2 ms 2044 KB Output is correct
10 Correct 2 ms 2044 KB Output is correct
11 Correct 3 ms 2044 KB Output is correct
12 Correct 2 ms 2044 KB Output is correct
13 Correct 2 ms 2044 KB Output is correct
14 Correct 3 ms 2044 KB Output is correct
15 Correct 2 ms 2044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2044 KB Output is correct
2 Correct 2 ms 2044 KB Output is correct
3 Correct 3 ms 2044 KB Output is correct
4 Correct 3 ms 2044 KB Output is correct
5 Correct 2 ms 2044 KB Output is correct
6 Correct 2 ms 2044 KB Output is correct
7 Correct 3 ms 2044 KB Output is correct
8 Correct 2 ms 2044 KB Output is correct
9 Correct 2 ms 2044 KB Output is correct
10 Correct 2 ms 2044 KB Output is correct
11 Correct 3 ms 2044 KB Output is correct
12 Correct 2 ms 2044 KB Output is correct
13 Correct 2 ms 2044 KB Output is correct
14 Correct 3 ms 2044 KB Output is correct
15 Correct 2 ms 2044 KB Output is correct
16 Correct 21 ms 2044 KB Output is correct
17 Correct 37 ms 2044 KB Output is correct
18 Correct 64 ms 2172 KB Output is correct
19 Correct 156 ms 2172 KB Output is correct
20 Correct 178 ms 2300 KB Output is correct
21 Correct 36 ms 2300 KB Output is correct
22 Correct 2 ms 2300 KB Output is correct
23 Correct 32 ms 2300 KB Output is correct
24 Correct 49 ms 2300 KB Output is correct
25 Correct 9 ms 2300 KB Output is correct
26 Correct 32 ms 2300 KB Output is correct
27 Correct 44 ms 2300 KB Output is correct
28 Correct 54 ms 2300 KB Output is correct
29 Correct 17 ms 2300 KB Output is correct
30 Correct 3 ms 2300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1504 KB Output is correct
2 Correct 10 ms 1504 KB Output is correct
3 Correct 37 ms 1504 KB Output is correct
4 Correct 25 ms 1504 KB Output is correct
5 Correct 30 ms 1504 KB Output is correct
6 Correct 19 ms 1504 KB Output is correct
7 Correct 5 ms 1504 KB Output is correct
8 Correct 19 ms 1504 KB Output is correct
9 Correct 48 ms 2044 KB Output is correct
10 Correct 28 ms 2044 KB Output is correct
11 Correct 2 ms 2044 KB Output is correct
12 Correct 2 ms 2044 KB Output is correct
13 Correct 3 ms 2044 KB Output is correct
14 Correct 3 ms 2044 KB Output is correct
15 Correct 2 ms 2044 KB Output is correct
16 Correct 2 ms 2044 KB Output is correct
17 Correct 3 ms 2044 KB Output is correct
18 Correct 2 ms 2044 KB Output is correct
19 Correct 2 ms 2044 KB Output is correct
20 Correct 2 ms 2044 KB Output is correct
21 Correct 3 ms 2044 KB Output is correct
22 Correct 2 ms 2044 KB Output is correct
23 Correct 2 ms 2044 KB Output is correct
24 Correct 3 ms 2044 KB Output is correct
25 Correct 2 ms 2044 KB Output is correct
26 Correct 21 ms 2044 KB Output is correct
27 Correct 37 ms 2044 KB Output is correct
28 Correct 64 ms 2172 KB Output is correct
29 Correct 156 ms 2172 KB Output is correct
30 Correct 178 ms 2300 KB Output is correct
31 Correct 36 ms 2300 KB Output is correct
32 Correct 2 ms 2300 KB Output is correct
33 Correct 32 ms 2300 KB Output is correct
34 Correct 49 ms 2300 KB Output is correct
35 Correct 9 ms 2300 KB Output is correct
36 Correct 32 ms 2300 KB Output is correct
37 Correct 44 ms 2300 KB Output is correct
38 Correct 54 ms 2300 KB Output is correct
39 Correct 17 ms 2300 KB Output is correct
40 Correct 3 ms 2300 KB Output is correct
41 Correct 139 ms 2300 KB Output is correct
42 Correct 56 ms 2300 KB Output is correct
43 Correct 86 ms 2300 KB Output is correct
44 Correct 57 ms 2300 KB Output is correct
45 Correct 49 ms 2300 KB Output is correct
46 Correct 150 ms 2300 KB Output is correct
47 Correct 43 ms 2300 KB Output is correct
48 Correct 73 ms 2300 KB Output is correct
49 Correct 54 ms 2300 KB Output is correct
50 Correct 674 ms 2300 KB Output is correct
51 Correct 683 ms 2300 KB Output is correct
52 Correct 623 ms 2300 KB Output is correct
53 Correct 702 ms 2300 KB Output is correct
54 Correct 634 ms 2300 KB Output is correct
55 Correct 689 ms 2300 KB Output is correct
56 Correct 605 ms 2300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 676 KB Output is correct
6 Correct 2 ms 676 KB Output is correct
7 Correct 2 ms 676 KB Output is correct
8 Correct 2 ms 676 KB Output is correct
9 Correct 36 ms 1504 KB Output is correct
10 Correct 10 ms 1504 KB Output is correct
11 Correct 37 ms 1504 KB Output is correct
12 Correct 25 ms 1504 KB Output is correct
13 Correct 30 ms 1504 KB Output is correct
14 Correct 19 ms 1504 KB Output is correct
15 Correct 5 ms 1504 KB Output is correct
16 Correct 19 ms 1504 KB Output is correct
17 Correct 48 ms 2044 KB Output is correct
18 Correct 28 ms 2044 KB Output is correct
19 Correct 2 ms 2044 KB Output is correct
20 Correct 2 ms 2044 KB Output is correct
21 Correct 3 ms 2044 KB Output is correct
22 Correct 3 ms 2044 KB Output is correct
23 Correct 2 ms 2044 KB Output is correct
24 Correct 2 ms 2044 KB Output is correct
25 Correct 3 ms 2044 KB Output is correct
26 Correct 2 ms 2044 KB Output is correct
27 Correct 2 ms 2044 KB Output is correct
28 Correct 2 ms 2044 KB Output is correct
29 Correct 3 ms 2044 KB Output is correct
30 Correct 2 ms 2044 KB Output is correct
31 Correct 2 ms 2044 KB Output is correct
32 Correct 3 ms 2044 KB Output is correct
33 Correct 2 ms 2044 KB Output is correct
34 Correct 21 ms 2044 KB Output is correct
35 Correct 37 ms 2044 KB Output is correct
36 Correct 64 ms 2172 KB Output is correct
37 Correct 156 ms 2172 KB Output is correct
38 Correct 178 ms 2300 KB Output is correct
39 Correct 36 ms 2300 KB Output is correct
40 Correct 2 ms 2300 KB Output is correct
41 Correct 32 ms 2300 KB Output is correct
42 Correct 49 ms 2300 KB Output is correct
43 Correct 9 ms 2300 KB Output is correct
44 Correct 32 ms 2300 KB Output is correct
45 Correct 44 ms 2300 KB Output is correct
46 Correct 54 ms 2300 KB Output is correct
47 Correct 17 ms 2300 KB Output is correct
48 Correct 3 ms 2300 KB Output is correct
49 Correct 139 ms 2300 KB Output is correct
50 Correct 56 ms 2300 KB Output is correct
51 Correct 86 ms 2300 KB Output is correct
52 Correct 57 ms 2300 KB Output is correct
53 Correct 49 ms 2300 KB Output is correct
54 Correct 150 ms 2300 KB Output is correct
55 Correct 43 ms 2300 KB Output is correct
56 Correct 73 ms 2300 KB Output is correct
57 Correct 54 ms 2300 KB Output is correct
58 Correct 674 ms 2300 KB Output is correct
59 Correct 683 ms 2300 KB Output is correct
60 Correct 623 ms 2300 KB Output is correct
61 Correct 702 ms 2300 KB Output is correct
62 Correct 634 ms 2300 KB Output is correct
63 Correct 689 ms 2300 KB Output is correct
64 Correct 605 ms 2300 KB Output is correct
65 Correct 2 ms 2300 KB Output is correct
66 Incorrect 2 ms 2300 KB Output isn't correct
67 Halted 0 ms 0 KB -