Submission #334478

# Submission time Handle Problem Language Result Execution time Memory
334478 2020-12-09T08:01:39 Z amunduzbaev Chessboard (IZhO18_chessboard) C++14
70 / 100
467 ms 3688 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 1;

vector<pii>vv;
ll ans, n, k;
 
void check(ll size){
	ll rem1 = ((n/size) * (n/size) +1)/2ll * size * size, er1 = 0;
	for(int i=0;i<sz(vv);i++){
		ll x = vv[i].ff / size, y = vv[i].ss / size;
		if((x + y) %2 == 0) rem1--;
		else er1++;
	}
	ans = min(ans, er1 + rem1);
	
	rem1 = ((n/size)* (n/size))/2ll * size * size, er1 = 0;
	for(int i=0;i<sz(vv);i++){
		ll x = vv[i].ff / size, y = vv[i].ss / size;
		if((x + y) % 2) rem1--;
		else er1++;
	}
	ans = min(ans, er1 + rem1);
}
 
void solve(){
	fastios
	ans = (ll)inf * (ll)inf;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		ll a, b, c, d;
		cin>>a>>b>>c>>d;
		vv.pb({--a, --b});
	}
	check(1);
	for(ll i=2;i *1ll * i<=n;i++){
		if(n % i == 0){
			check(i);
			check(n/i);
		}
	}
	cout<<ans<<"\n";
	return;
}
/*
 
6 8
1 2 1 2
2 1 2 1
3 3 3 3
3 4 3 4
4 3 4 3
4 4 4 4
3 6 3 6
5 5 5 5
 
*/
int main(){
	fastios
	int t = 1;
	//cin>>t;
	while(t--) solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1008 KB Output is correct
2 Correct 7 ms 1132 KB Output is correct
3 Correct 19 ms 1904 KB Output is correct
4 Correct 19 ms 1796 KB Output is correct
5 Correct 23 ms 2156 KB Output is correct
6 Correct 15 ms 1776 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 15 ms 1776 KB Output is correct
9 Correct 38 ms 3304 KB Output is correct
10 Correct 21 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 13 ms 748 KB Output is correct
17 Correct 29 ms 1644 KB Output is correct
18 Correct 41 ms 1516 KB Output is correct
19 Correct 104 ms 1516 KB Output is correct
20 Correct 123 ms 1516 KB Output is correct
21 Correct 30 ms 1516 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 25 ms 1008 KB Output is correct
24 Correct 37 ms 1516 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 24 ms 1008 KB Output is correct
27 Correct 33 ms 1516 KB Output is correct
28 Correct 39 ms 1516 KB Output is correct
29 Correct 12 ms 1008 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1008 KB Output is correct
2 Correct 7 ms 1132 KB Output is correct
3 Correct 19 ms 1904 KB Output is correct
4 Correct 19 ms 1796 KB Output is correct
5 Correct 23 ms 2156 KB Output is correct
6 Correct 15 ms 1776 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 15 ms 1776 KB Output is correct
9 Correct 38 ms 3304 KB Output is correct
10 Correct 21 ms 2032 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 13 ms 748 KB Output is correct
27 Correct 29 ms 1644 KB Output is correct
28 Correct 41 ms 1516 KB Output is correct
29 Correct 104 ms 1516 KB Output is correct
30 Correct 123 ms 1516 KB Output is correct
31 Correct 30 ms 1516 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 25 ms 1008 KB Output is correct
34 Correct 37 ms 1516 KB Output is correct
35 Correct 5 ms 492 KB Output is correct
36 Correct 24 ms 1008 KB Output is correct
37 Correct 33 ms 1516 KB Output is correct
38 Correct 39 ms 1516 KB Output is correct
39 Correct 12 ms 1008 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 96 ms 3308 KB Output is correct
42 Correct 45 ms 3452 KB Output is correct
43 Correct 63 ms 3308 KB Output is correct
44 Correct 44 ms 3308 KB Output is correct
45 Correct 41 ms 3560 KB Output is correct
46 Correct 108 ms 3432 KB Output is correct
47 Correct 36 ms 3308 KB Output is correct
48 Correct 55 ms 3308 KB Output is correct
49 Correct 40 ms 3308 KB Output is correct
50 Correct 430 ms 3476 KB Output is correct
51 Correct 456 ms 3688 KB Output is correct
52 Correct 417 ms 3308 KB Output is correct
53 Correct 447 ms 3688 KB Output is correct
54 Correct 416 ms 3308 KB Output is correct
55 Correct 467 ms 3688 KB Output is correct
56 Correct 407 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 25 ms 1008 KB Output is correct
10 Correct 7 ms 1132 KB Output is correct
11 Correct 19 ms 1904 KB Output is correct
12 Correct 19 ms 1796 KB Output is correct
13 Correct 23 ms 2156 KB Output is correct
14 Correct 15 ms 1776 KB Output is correct
15 Correct 4 ms 620 KB Output is correct
16 Correct 15 ms 1776 KB Output is correct
17 Correct 38 ms 3304 KB Output is correct
18 Correct 21 ms 2032 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 13 ms 748 KB Output is correct
35 Correct 29 ms 1644 KB Output is correct
36 Correct 41 ms 1516 KB Output is correct
37 Correct 104 ms 1516 KB Output is correct
38 Correct 123 ms 1516 KB Output is correct
39 Correct 30 ms 1516 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 25 ms 1008 KB Output is correct
42 Correct 37 ms 1516 KB Output is correct
43 Correct 5 ms 492 KB Output is correct
44 Correct 24 ms 1008 KB Output is correct
45 Correct 33 ms 1516 KB Output is correct
46 Correct 39 ms 1516 KB Output is correct
47 Correct 12 ms 1008 KB Output is correct
48 Correct 2 ms 364 KB Output is correct
49 Correct 96 ms 3308 KB Output is correct
50 Correct 45 ms 3452 KB Output is correct
51 Correct 63 ms 3308 KB Output is correct
52 Correct 44 ms 3308 KB Output is correct
53 Correct 41 ms 3560 KB Output is correct
54 Correct 108 ms 3432 KB Output is correct
55 Correct 36 ms 3308 KB Output is correct
56 Correct 55 ms 3308 KB Output is correct
57 Correct 40 ms 3308 KB Output is correct
58 Correct 430 ms 3476 KB Output is correct
59 Correct 456 ms 3688 KB Output is correct
60 Correct 417 ms 3308 KB Output is correct
61 Correct 447 ms 3688 KB Output is correct
62 Correct 416 ms 3308 KB Output is correct
63 Correct 467 ms 3688 KB Output is correct
64 Correct 407 ms 3308 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Incorrect 1 ms 364 KB Output isn't correct
67 Halted 0 ms 0 KB -