답안 #237229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237229 2020-06-05T10:14:27 Z kshitij_sodani Chessboard (IZhO18_chessboard) C++17
70 / 100
379 ms 4584 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
llo n,k;
llo aa,bb,cc,dd;
vector<pair<llo,llo>> cur;
llo check(llo nn){
	if(nn==n){
		return n*n;
	}
	llo co;
	if((n/nn)%2==0){
		co=(n*n)/2;
	}
	else{
		co=(n*n-nn*nn)/2;
	}
	//cout<<co<<":";
	for(auto i:cur){
		if((i.a/nn+i.b/nn)%2==1){
			co-=1;
		}
		else{
			co+=1;
		}
	}
	llo co2;
	if((n/nn)%2==0){
		co2=(n*n)/2;
	}
	else{
		co2=(n*n+nn*nn)/2;
	}
//	cout<<co2<<endl;
	for(auto i:cur){
		if((i.a/nn+i.b/nn)%2==0){
			co2-=1;
		}
		else{
			co2+=1;
		}
	}
//	cout<<nn<<","<<co<<","<<co2<<endl;
	return min(co,co2);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;

	for(llo i=0;i<k;i++){
		cin>>aa>>bb>>cc>>dd;
		aa-=1;
		bb-=1;
		cur.pb({aa,bb});
	}
	llo ans=n*n;
	for(llo i=1;i*i<=n;i++){
		if(n%i==0){
			ans=min(ans,check(i));
			ans=min(ans,check(n/i));
		}
	}
	cout<<ans<<endl;



	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 1652 KB Output is correct
2 Correct 11 ms 1408 KB Output is correct
3 Correct 24 ms 2428 KB Output is correct
4 Correct 23 ms 2300 KB Output is correct
5 Correct 30 ms 2672 KB Output is correct
6 Correct 21 ms 2300 KB Output is correct
7 Correct 8 ms 768 KB Output is correct
8 Correct 21 ms 2292 KB Output is correct
9 Correct 46 ms 4208 KB Output is correct
10 Correct 27 ms 2556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 16 ms 1152 KB Output is correct
17 Correct 34 ms 2672 KB Output is correct
18 Correct 44 ms 2680 KB Output is correct
19 Correct 91 ms 2672 KB Output is correct
20 Correct 100 ms 2672 KB Output is correct
21 Correct 35 ms 2680 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 25 ms 1660 KB Output is correct
24 Correct 41 ms 2680 KB Output is correct
25 Correct 9 ms 896 KB Output is correct
26 Correct 28 ms 1660 KB Output is correct
27 Correct 35 ms 2672 KB Output is correct
28 Correct 42 ms 2672 KB Output is correct
29 Correct 17 ms 1660 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 1652 KB Output is correct
2 Correct 11 ms 1408 KB Output is correct
3 Correct 24 ms 2428 KB Output is correct
4 Correct 23 ms 2300 KB Output is correct
5 Correct 30 ms 2672 KB Output is correct
6 Correct 21 ms 2300 KB Output is correct
7 Correct 8 ms 768 KB Output is correct
8 Correct 21 ms 2292 KB Output is correct
9 Correct 46 ms 4208 KB Output is correct
10 Correct 27 ms 2556 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 16 ms 1152 KB Output is correct
27 Correct 34 ms 2672 KB Output is correct
28 Correct 44 ms 2680 KB Output is correct
29 Correct 91 ms 2672 KB Output is correct
30 Correct 100 ms 2672 KB Output is correct
31 Correct 35 ms 2680 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 25 ms 1660 KB Output is correct
34 Correct 41 ms 2680 KB Output is correct
35 Correct 9 ms 896 KB Output is correct
36 Correct 28 ms 1660 KB Output is correct
37 Correct 35 ms 2672 KB Output is correct
38 Correct 42 ms 2672 KB Output is correct
39 Correct 17 ms 1660 KB Output is correct
40 Correct 6 ms 512 KB Output is correct
41 Correct 94 ms 4336 KB Output is correct
42 Correct 55 ms 4336 KB Output is correct
43 Correct 68 ms 4336 KB Output is correct
44 Correct 52 ms 4332 KB Output is correct
45 Correct 49 ms 4336 KB Output is correct
46 Correct 104 ms 4332 KB Output is correct
47 Correct 45 ms 4336 KB Output is correct
48 Correct 60 ms 4344 KB Output is correct
49 Correct 49 ms 4344 KB Output is correct
50 Correct 343 ms 4336 KB Output is correct
51 Correct 366 ms 4456 KB Output is correct
52 Correct 342 ms 4328 KB Output is correct
53 Correct 366 ms 4456 KB Output is correct
54 Correct 337 ms 4336 KB Output is correct
55 Correct 379 ms 4584 KB Output is correct
56 Correct 325 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 34 ms 1652 KB Output is correct
10 Correct 11 ms 1408 KB Output is correct
11 Correct 24 ms 2428 KB Output is correct
12 Correct 23 ms 2300 KB Output is correct
13 Correct 30 ms 2672 KB Output is correct
14 Correct 21 ms 2300 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 21 ms 2292 KB Output is correct
17 Correct 46 ms 4208 KB Output is correct
18 Correct 27 ms 2556 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 16 ms 1152 KB Output is correct
35 Correct 34 ms 2672 KB Output is correct
36 Correct 44 ms 2680 KB Output is correct
37 Correct 91 ms 2672 KB Output is correct
38 Correct 100 ms 2672 KB Output is correct
39 Correct 35 ms 2680 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 25 ms 1660 KB Output is correct
42 Correct 41 ms 2680 KB Output is correct
43 Correct 9 ms 896 KB Output is correct
44 Correct 28 ms 1660 KB Output is correct
45 Correct 35 ms 2672 KB Output is correct
46 Correct 42 ms 2672 KB Output is correct
47 Correct 17 ms 1660 KB Output is correct
48 Correct 6 ms 512 KB Output is correct
49 Correct 94 ms 4336 KB Output is correct
50 Correct 55 ms 4336 KB Output is correct
51 Correct 68 ms 4336 KB Output is correct
52 Correct 52 ms 4332 KB Output is correct
53 Correct 49 ms 4336 KB Output is correct
54 Correct 104 ms 4332 KB Output is correct
55 Correct 45 ms 4336 KB Output is correct
56 Correct 60 ms 4344 KB Output is correct
57 Correct 49 ms 4344 KB Output is correct
58 Correct 343 ms 4336 KB Output is correct
59 Correct 366 ms 4456 KB Output is correct
60 Correct 342 ms 4328 KB Output is correct
61 Correct 366 ms 4456 KB Output is correct
62 Correct 337 ms 4336 KB Output is correct
63 Correct 379 ms 4584 KB Output is correct
64 Correct 325 ms 4344 KB Output is correct
65 Correct 4 ms 384 KB Output is correct
66 Incorrect 5 ms 384 KB Output isn't correct
67 Halted 0 ms 0 KB -