답안 #378569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378569 2021-03-17T01:49:58 Z ElaineHuang Chessboard (IZhO18_chessboard) C++14
70 / 100
270 ms 2924 KB
#include<bits/stdc++.h>
#define debug 0
#define int long long
#define min trash
using namespace std;
int b[100005][2];//black squares
//vector<int> factor;
int factor[100005],fs;//factor size
int N;
int Min(int a,int b)
{
	return a<b?a:b;
}
int p(int f)
{
	int o=((N/f)*(N/f)/2)*f*f;//o->odd blocks
	int e=N*N-o;//e->even blocks
	if(debug) printf("f%lld o%lld e%lld\n",f,o,e);//
	return Min(b[f][1]+e-b[f][0],b[f][0]+o-b[f][1]);//e黑//o黑 
}
signed main()
{
	int K,x1,x2,y1,y2;
	scanf("%lld %lld",&N,&K);
	int g=(int)sqrt(N);
	//factor.clear();
	memset(b,0,sizeof(b));
	for(int i=1;i<=g;i++)
	{
		if(!(N%i))
		{
			factor[fs]=i;
			fs++;
		}
		if(debug) printf("i=%lld\n",i);//
	}
	if(debug) printf("%lld, g%lld\n",fs,g);//
	while(K--)
	{
		scanf("%lld %lld %lld %lld",&x1,&y1,&x2,&y2);
		x1--,y1--,x2--,y2--;
		for(int i=0;i<fs;i++)
		{
			int a;//determine 0 or 1
			int f;//factor
			f=factor[i];
			a=x1/f+y1/f;
			a%=2;
			b[f][a]++;
			
			if(f==N/f) break;
			if(f==1) continue;
			
			f=N/factor[i];
			a=x1/f+y1/f;
			a%=2;
			b[f][a]++;
		}
	}
	int ans=N*N;
	for(int i=0;i<fs;i++)
	{
		int f;
		f=factor[i];//p->paint幾格 
		ans=Min(p(f),ans);
		if(f==N/f) break;
		if(f==1) continue;
		f=N/f;
		ans=Min(p(f),ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |  scanf("%lld %lld",&N,&K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
chessboard.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |   scanf("%lld %lld %lld %lld",&x1,&y1,&x2,&y2);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1900 KB Output is correct
2 Correct 1 ms 1900 KB Output is correct
3 Correct 1 ms 1900 KB Output is correct
4 Correct 3 ms 1900 KB Output is correct
5 Correct 3 ms 1900 KB Output is correct
6 Correct 3 ms 1900 KB Output is correct
7 Correct 1 ms 1900 KB Output is correct
8 Correct 1 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1900 KB Output is correct
2 Correct 8 ms 1900 KB Output is correct
3 Correct 17 ms 1900 KB Output is correct
4 Correct 42 ms 1900 KB Output is correct
5 Correct 30 ms 1900 KB Output is correct
6 Correct 15 ms 1900 KB Output is correct
7 Correct 4 ms 1900 KB Output is correct
8 Correct 16 ms 2028 KB Output is correct
9 Correct 50 ms 1900 KB Output is correct
10 Correct 21 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1900 KB Output is correct
2 Correct 1 ms 1900 KB Output is correct
3 Correct 2 ms 1900 KB Output is correct
4 Correct 4 ms 1900 KB Output is correct
5 Correct 3 ms 1900 KB Output is correct
6 Correct 2 ms 1900 KB Output is correct
7 Correct 3 ms 1900 KB Output is correct
8 Correct 3 ms 1900 KB Output is correct
9 Correct 3 ms 1900 KB Output is correct
10 Correct 3 ms 1900 KB Output is correct
11 Correct 3 ms 1900 KB Output is correct
12 Correct 2 ms 1900 KB Output is correct
13 Correct 3 ms 1900 KB Output is correct
14 Correct 3 ms 1900 KB Output is correct
15 Correct 3 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1900 KB Output is correct
2 Correct 1 ms 1900 KB Output is correct
3 Correct 2 ms 1900 KB Output is correct
4 Correct 4 ms 1900 KB Output is correct
5 Correct 3 ms 1900 KB Output is correct
6 Correct 2 ms 1900 KB Output is correct
7 Correct 3 ms 1900 KB Output is correct
8 Correct 3 ms 1900 KB Output is correct
9 Correct 3 ms 1900 KB Output is correct
10 Correct 3 ms 1900 KB Output is correct
11 Correct 3 ms 1900 KB Output is correct
12 Correct 2 ms 1900 KB Output is correct
13 Correct 3 ms 1900 KB Output is correct
14 Correct 3 ms 1900 KB Output is correct
15 Correct 3 ms 1900 KB Output is correct
16 Correct 11 ms 1900 KB Output is correct
17 Correct 29 ms 1900 KB Output is correct
18 Correct 38 ms 1944 KB Output is correct
19 Correct 69 ms 2048 KB Output is correct
20 Correct 77 ms 1944 KB Output is correct
21 Correct 28 ms 1900 KB Output is correct
22 Correct 2 ms 1900 KB Output is correct
23 Correct 26 ms 1900 KB Output is correct
24 Correct 35 ms 1900 KB Output is correct
25 Correct 6 ms 1900 KB Output is correct
26 Correct 22 ms 1900 KB Output is correct
27 Correct 29 ms 1920 KB Output is correct
28 Correct 37 ms 1900 KB Output is correct
29 Correct 12 ms 1900 KB Output is correct
30 Correct 2 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1900 KB Output is correct
2 Correct 8 ms 1900 KB Output is correct
3 Correct 17 ms 1900 KB Output is correct
4 Correct 42 ms 1900 KB Output is correct
5 Correct 30 ms 1900 KB Output is correct
6 Correct 15 ms 1900 KB Output is correct
7 Correct 4 ms 1900 KB Output is correct
8 Correct 16 ms 2028 KB Output is correct
9 Correct 50 ms 1900 KB Output is correct
10 Correct 21 ms 1900 KB Output is correct
11 Correct 2 ms 1900 KB Output is correct
12 Correct 1 ms 1900 KB Output is correct
13 Correct 2 ms 1900 KB Output is correct
14 Correct 4 ms 1900 KB Output is correct
15 Correct 3 ms 1900 KB Output is correct
16 Correct 2 ms 1900 KB Output is correct
17 Correct 3 ms 1900 KB Output is correct
18 Correct 3 ms 1900 KB Output is correct
19 Correct 3 ms 1900 KB Output is correct
20 Correct 3 ms 1900 KB Output is correct
21 Correct 3 ms 1900 KB Output is correct
22 Correct 2 ms 1900 KB Output is correct
23 Correct 3 ms 1900 KB Output is correct
24 Correct 3 ms 1900 KB Output is correct
25 Correct 3 ms 1900 KB Output is correct
26 Correct 11 ms 1900 KB Output is correct
27 Correct 29 ms 1900 KB Output is correct
28 Correct 38 ms 1944 KB Output is correct
29 Correct 69 ms 2048 KB Output is correct
30 Correct 77 ms 1944 KB Output is correct
31 Correct 28 ms 1900 KB Output is correct
32 Correct 2 ms 1900 KB Output is correct
33 Correct 26 ms 1900 KB Output is correct
34 Correct 35 ms 1900 KB Output is correct
35 Correct 6 ms 1900 KB Output is correct
36 Correct 22 ms 1900 KB Output is correct
37 Correct 29 ms 1920 KB Output is correct
38 Correct 37 ms 1900 KB Output is correct
39 Correct 12 ms 1900 KB Output is correct
40 Correct 2 ms 1900 KB Output is correct
41 Correct 68 ms 1900 KB Output is correct
42 Correct 41 ms 1900 KB Output is correct
43 Correct 49 ms 1900 KB Output is correct
44 Correct 40 ms 1900 KB Output is correct
45 Correct 38 ms 1900 KB Output is correct
46 Correct 75 ms 2028 KB Output is correct
47 Correct 34 ms 1900 KB Output is correct
48 Correct 44 ms 1900 KB Output is correct
49 Correct 36 ms 1900 KB Output is correct
50 Correct 245 ms 2156 KB Output is correct
51 Correct 260 ms 2028 KB Output is correct
52 Correct 243 ms 2924 KB Output is correct
53 Correct 256 ms 2668 KB Output is correct
54 Correct 239 ms 2516 KB Output is correct
55 Correct 270 ms 2796 KB Output is correct
56 Correct 229 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1900 KB Output is correct
2 Correct 1 ms 1900 KB Output is correct
3 Correct 1 ms 1900 KB Output is correct
4 Correct 3 ms 1900 KB Output is correct
5 Correct 3 ms 1900 KB Output is correct
6 Correct 3 ms 1900 KB Output is correct
7 Correct 1 ms 1900 KB Output is correct
8 Correct 1 ms 1900 KB Output is correct
9 Correct 25 ms 1900 KB Output is correct
10 Correct 8 ms 1900 KB Output is correct
11 Correct 17 ms 1900 KB Output is correct
12 Correct 42 ms 1900 KB Output is correct
13 Correct 30 ms 1900 KB Output is correct
14 Correct 15 ms 1900 KB Output is correct
15 Correct 4 ms 1900 KB Output is correct
16 Correct 16 ms 2028 KB Output is correct
17 Correct 50 ms 1900 KB Output is correct
18 Correct 21 ms 1900 KB Output is correct
19 Correct 2 ms 1900 KB Output is correct
20 Correct 1 ms 1900 KB Output is correct
21 Correct 2 ms 1900 KB Output is correct
22 Correct 4 ms 1900 KB Output is correct
23 Correct 3 ms 1900 KB Output is correct
24 Correct 2 ms 1900 KB Output is correct
25 Correct 3 ms 1900 KB Output is correct
26 Correct 3 ms 1900 KB Output is correct
27 Correct 3 ms 1900 KB Output is correct
28 Correct 3 ms 1900 KB Output is correct
29 Correct 3 ms 1900 KB Output is correct
30 Correct 2 ms 1900 KB Output is correct
31 Correct 3 ms 1900 KB Output is correct
32 Correct 3 ms 1900 KB Output is correct
33 Correct 3 ms 1900 KB Output is correct
34 Correct 11 ms 1900 KB Output is correct
35 Correct 29 ms 1900 KB Output is correct
36 Correct 38 ms 1944 KB Output is correct
37 Correct 69 ms 2048 KB Output is correct
38 Correct 77 ms 1944 KB Output is correct
39 Correct 28 ms 1900 KB Output is correct
40 Correct 2 ms 1900 KB Output is correct
41 Correct 26 ms 1900 KB Output is correct
42 Correct 35 ms 1900 KB Output is correct
43 Correct 6 ms 1900 KB Output is correct
44 Correct 22 ms 1900 KB Output is correct
45 Correct 29 ms 1920 KB Output is correct
46 Correct 37 ms 1900 KB Output is correct
47 Correct 12 ms 1900 KB Output is correct
48 Correct 2 ms 1900 KB Output is correct
49 Correct 68 ms 1900 KB Output is correct
50 Correct 41 ms 1900 KB Output is correct
51 Correct 49 ms 1900 KB Output is correct
52 Correct 40 ms 1900 KB Output is correct
53 Correct 38 ms 1900 KB Output is correct
54 Correct 75 ms 2028 KB Output is correct
55 Correct 34 ms 1900 KB Output is correct
56 Correct 44 ms 1900 KB Output is correct
57 Correct 36 ms 1900 KB Output is correct
58 Correct 245 ms 2156 KB Output is correct
59 Correct 260 ms 2028 KB Output is correct
60 Correct 243 ms 2924 KB Output is correct
61 Correct 256 ms 2668 KB Output is correct
62 Correct 239 ms 2516 KB Output is correct
63 Correct 270 ms 2796 KB Output is correct
64 Correct 229 ms 2412 KB Output is correct
65 Correct 1 ms 1900 KB Output is correct
66 Incorrect 1 ms 1900 KB Output isn't correct
67 Halted 0 ms 0 KB -