Submission #68097

# Submission time Handle Problem Language Result Execution time Memory
68097 2018-08-15T22:19:38 Z MatheusLealV Chessboard (IZhO18_chessboard) C++17
70 / 100
561 ms 60864 KB
#include <bits/stdc++.h>
#define N 100050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

ll n, k, x[N], y[N], xf[N], yf[N];

long long ans = (2000000000000000000ll);

vector<ll> d;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>k;

	for(int i = 1; i <= k; i++) cin>>x[i]>>y[i]>>xf[i]>>yf[i];

	for(int i = 1; i <= k; i++) x[i] --, y[i] --, xf[i] --, yf[i] --;

	for(int i = 1; i <= sqrt(n); i++)
	{
		if((n % i) != 0) continue;

		d.push_back(i);

		if(i != n/i) d.push_back(n/i);
	}

	for(auto r: d)
	{	
		ll pretocerto = 0, pretoerrado = 0, tot;

		if(r == n) continue;

		tot = ( ((n/r) * (n/r)) + 1LL)/2LL;

		tot = (tot * r * r); 

		//if(r != 2) continue;

		for(int i = 1; i <= k; i++)
		{
			int linha = (x[i] % (2*r) < r ? 1 : 0), coluna = (y[i] % (2*r) < r ? 1 : 0);

			if(!linha) coluna = !coluna;

			if(!coluna) pretoerrado ++;

			else pretocerto ++;
		}

		//cout<<custo<<" "<<branco<<"\n";

		ans = min(ans, tot - pretocerto + pretoerrado);

		tot = ( ((n/r) * (n/r)))/2LL;

		tot = (tot * r * r); 

		ans = min(ans, tot + pretocerto - pretoerrado);

	}

	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 2 ms 664 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2620 KB Output is correct
2 Correct 9 ms 2620 KB Output is correct
3 Correct 25 ms 2876 KB Output is correct
4 Correct 34 ms 3920 KB Output is correct
5 Correct 33 ms 5532 KB Output is correct
6 Correct 21 ms 5716 KB Output is correct
7 Correct 6 ms 5716 KB Output is correct
8 Correct 22 ms 6752 KB Output is correct
9 Correct 49 ms 10520 KB Output is correct
10 Correct 25 ms 10520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10520 KB Output is correct
2 Correct 2 ms 10520 KB Output is correct
3 Correct 2 ms 10520 KB Output is correct
4 Correct 4 ms 10520 KB Output is correct
5 Correct 2 ms 10520 KB Output is correct
6 Correct 3 ms 10520 KB Output is correct
7 Correct 3 ms 10520 KB Output is correct
8 Correct 3 ms 10520 KB Output is correct
9 Correct 3 ms 10520 KB Output is correct
10 Correct 3 ms 10520 KB Output is correct
11 Correct 3 ms 10520 KB Output is correct
12 Correct 3 ms 10520 KB Output is correct
13 Correct 3 ms 10520 KB Output is correct
14 Correct 3 ms 10520 KB Output is correct
15 Correct 4 ms 10520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10520 KB Output is correct
2 Correct 2 ms 10520 KB Output is correct
3 Correct 2 ms 10520 KB Output is correct
4 Correct 4 ms 10520 KB Output is correct
5 Correct 2 ms 10520 KB Output is correct
6 Correct 3 ms 10520 KB Output is correct
7 Correct 3 ms 10520 KB Output is correct
8 Correct 3 ms 10520 KB Output is correct
9 Correct 3 ms 10520 KB Output is correct
10 Correct 3 ms 10520 KB Output is correct
11 Correct 3 ms 10520 KB Output is correct
12 Correct 3 ms 10520 KB Output is correct
13 Correct 3 ms 10520 KB Output is correct
14 Correct 3 ms 10520 KB Output is correct
15 Correct 4 ms 10520 KB Output is correct
16 Correct 15 ms 10520 KB Output is correct
17 Correct 34 ms 13524 KB Output is correct
18 Correct 77 ms 15524 KB Output is correct
19 Correct 155 ms 16740 KB Output is correct
20 Correct 192 ms 18552 KB Output is correct
21 Correct 37 ms 19380 KB Output is correct
22 Correct 3 ms 19380 KB Output is correct
23 Correct 43 ms 19380 KB Output is correct
24 Correct 50 ms 21788 KB Output is correct
25 Correct 12 ms 21788 KB Output is correct
26 Correct 46 ms 21872 KB Output is correct
27 Correct 42 ms 23296 KB Output is correct
28 Correct 51 ms 25804 KB Output is correct
29 Correct 18 ms 25804 KB Output is correct
30 Correct 4 ms 25804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2620 KB Output is correct
2 Correct 9 ms 2620 KB Output is correct
3 Correct 25 ms 2876 KB Output is correct
4 Correct 34 ms 3920 KB Output is correct
5 Correct 33 ms 5532 KB Output is correct
6 Correct 21 ms 5716 KB Output is correct
7 Correct 6 ms 5716 KB Output is correct
8 Correct 22 ms 6752 KB Output is correct
9 Correct 49 ms 10520 KB Output is correct
10 Correct 25 ms 10520 KB Output is correct
11 Correct 3 ms 10520 KB Output is correct
12 Correct 2 ms 10520 KB Output is correct
13 Correct 2 ms 10520 KB Output is correct
14 Correct 4 ms 10520 KB Output is correct
15 Correct 2 ms 10520 KB Output is correct
16 Correct 3 ms 10520 KB Output is correct
17 Correct 3 ms 10520 KB Output is correct
18 Correct 3 ms 10520 KB Output is correct
19 Correct 3 ms 10520 KB Output is correct
20 Correct 3 ms 10520 KB Output is correct
21 Correct 3 ms 10520 KB Output is correct
22 Correct 3 ms 10520 KB Output is correct
23 Correct 3 ms 10520 KB Output is correct
24 Correct 3 ms 10520 KB Output is correct
25 Correct 4 ms 10520 KB Output is correct
26 Correct 15 ms 10520 KB Output is correct
27 Correct 34 ms 13524 KB Output is correct
28 Correct 77 ms 15524 KB Output is correct
29 Correct 155 ms 16740 KB Output is correct
30 Correct 192 ms 18552 KB Output is correct
31 Correct 37 ms 19380 KB Output is correct
32 Correct 3 ms 19380 KB Output is correct
33 Correct 43 ms 19380 KB Output is correct
34 Correct 50 ms 21788 KB Output is correct
35 Correct 12 ms 21788 KB Output is correct
36 Correct 46 ms 21872 KB Output is correct
37 Correct 42 ms 23296 KB Output is correct
38 Correct 51 ms 25804 KB Output is correct
39 Correct 18 ms 25804 KB Output is correct
40 Correct 4 ms 25804 KB Output is correct
41 Correct 118 ms 27832 KB Output is correct
42 Correct 53 ms 30444 KB Output is correct
43 Correct 75 ms 32188 KB Output is correct
44 Correct 54 ms 34568 KB Output is correct
45 Correct 51 ms 37136 KB Output is correct
46 Correct 128 ms 39164 KB Output is correct
47 Correct 41 ms 41084 KB Output is correct
48 Correct 64 ms 43244 KB Output is correct
49 Correct 46 ms 45112 KB Output is correct
50 Correct 492 ms 47636 KB Output is correct
51 Correct 546 ms 50076 KB Output is correct
52 Correct 528 ms 52132 KB Output is correct
53 Correct 534 ms 54556 KB Output is correct
54 Correct 487 ms 56456 KB Output is correct
55 Correct 561 ms 59144 KB Output is correct
56 Correct 471 ms 60864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 2 ms 664 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 32 ms 2620 KB Output is correct
10 Correct 9 ms 2620 KB Output is correct
11 Correct 25 ms 2876 KB Output is correct
12 Correct 34 ms 3920 KB Output is correct
13 Correct 33 ms 5532 KB Output is correct
14 Correct 21 ms 5716 KB Output is correct
15 Correct 6 ms 5716 KB Output is correct
16 Correct 22 ms 6752 KB Output is correct
17 Correct 49 ms 10520 KB Output is correct
18 Correct 25 ms 10520 KB Output is correct
19 Correct 3 ms 10520 KB Output is correct
20 Correct 2 ms 10520 KB Output is correct
21 Correct 2 ms 10520 KB Output is correct
22 Correct 4 ms 10520 KB Output is correct
23 Correct 2 ms 10520 KB Output is correct
24 Correct 3 ms 10520 KB Output is correct
25 Correct 3 ms 10520 KB Output is correct
26 Correct 3 ms 10520 KB Output is correct
27 Correct 3 ms 10520 KB Output is correct
28 Correct 3 ms 10520 KB Output is correct
29 Correct 3 ms 10520 KB Output is correct
30 Correct 3 ms 10520 KB Output is correct
31 Correct 3 ms 10520 KB Output is correct
32 Correct 3 ms 10520 KB Output is correct
33 Correct 4 ms 10520 KB Output is correct
34 Correct 15 ms 10520 KB Output is correct
35 Correct 34 ms 13524 KB Output is correct
36 Correct 77 ms 15524 KB Output is correct
37 Correct 155 ms 16740 KB Output is correct
38 Correct 192 ms 18552 KB Output is correct
39 Correct 37 ms 19380 KB Output is correct
40 Correct 3 ms 19380 KB Output is correct
41 Correct 43 ms 19380 KB Output is correct
42 Correct 50 ms 21788 KB Output is correct
43 Correct 12 ms 21788 KB Output is correct
44 Correct 46 ms 21872 KB Output is correct
45 Correct 42 ms 23296 KB Output is correct
46 Correct 51 ms 25804 KB Output is correct
47 Correct 18 ms 25804 KB Output is correct
48 Correct 4 ms 25804 KB Output is correct
49 Correct 118 ms 27832 KB Output is correct
50 Correct 53 ms 30444 KB Output is correct
51 Correct 75 ms 32188 KB Output is correct
52 Correct 54 ms 34568 KB Output is correct
53 Correct 51 ms 37136 KB Output is correct
54 Correct 128 ms 39164 KB Output is correct
55 Correct 41 ms 41084 KB Output is correct
56 Correct 64 ms 43244 KB Output is correct
57 Correct 46 ms 45112 KB Output is correct
58 Correct 492 ms 47636 KB Output is correct
59 Correct 546 ms 50076 KB Output is correct
60 Correct 528 ms 52132 KB Output is correct
61 Correct 534 ms 54556 KB Output is correct
62 Correct 487 ms 56456 KB Output is correct
63 Correct 561 ms 59144 KB Output is correct
64 Correct 471 ms 60864 KB Output is correct
65 Correct 3 ms 60864 KB Output is correct
66 Incorrect 2 ms 60864 KB Output isn't correct
67 Halted 0 ms 0 KB -