#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define all(x) x.begin(),x.end()
#define al(a,n) (a,a+n)
#define se second
#define fr first
#define m_p make_pair
const ll N = 1005;
const ll mod = 1000 * 1000 * 1000 + 7;
const ll inf = 1000000009;
ll n, m, k, z, t, x, y, ans, pat,a[N][N];
pair<ll, ll> p[N][N];
vector<pair<ll, ll>> v;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < m; ++i)
{
cin >> x >> y >> x >> y;
v.push_back({ x-1,y-1 });
}
ans = inf*inf;
for (int ii = 1; ii <= n/2; ++ii)
{
x = 0;
y = 0;
if (n % ii == 0)
{
for (int i = 0; i < m; ++i)
{
if ((v[i].first / ii + v[i].second / ii) % 2 == 0)
{
x++;
}
else
y++;
}
k = n / ii;
k *= k;
z = k / 2;
if (k % 2 == 1)
z++;
k /= 2;
ans = min(ans, min(z*ii*ii-x+y,k*ii*ii-y+x));
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1484 KB |
Output is correct |
2 |
Correct |
6 ms |
976 KB |
Output is correct |
3 |
Correct |
13 ms |
1484 KB |
Output is correct |
4 |
Correct |
12 ms |
1436 KB |
Output is correct |
5 |
Correct |
17 ms |
1420 KB |
Output is correct |
6 |
Correct |
13 ms |
1532 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
11 ms |
1484 KB |
Output is correct |
9 |
Correct |
28 ms |
2400 KB |
Output is correct |
10 |
Correct |
16 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
7 ms |
976 KB |
Output is correct |
17 |
Correct |
23 ms |
2500 KB |
Output is correct |
18 |
Correct |
29 ms |
2504 KB |
Output is correct |
19 |
Correct |
54 ms |
2508 KB |
Output is correct |
20 |
Correct |
58 ms |
2504 KB |
Output is correct |
21 |
Correct |
20 ms |
2484 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
15 ms |
1484 KB |
Output is correct |
24 |
Correct |
25 ms |
2504 KB |
Output is correct |
25 |
Correct |
3 ms |
592 KB |
Output is correct |
26 |
Correct |
17 ms |
1468 KB |
Output is correct |
27 |
Correct |
21 ms |
2488 KB |
Output is correct |
28 |
Correct |
28 ms |
2456 KB |
Output is correct |
29 |
Correct |
12 ms |
1484 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1484 KB |
Output is correct |
2 |
Correct |
6 ms |
976 KB |
Output is correct |
3 |
Correct |
13 ms |
1484 KB |
Output is correct |
4 |
Correct |
12 ms |
1436 KB |
Output is correct |
5 |
Correct |
17 ms |
1420 KB |
Output is correct |
6 |
Correct |
13 ms |
1532 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
11 ms |
1484 KB |
Output is correct |
9 |
Correct |
28 ms |
2400 KB |
Output is correct |
10 |
Correct |
16 ms |
1484 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
0 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
0 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
7 ms |
976 KB |
Output is correct |
27 |
Correct |
23 ms |
2500 KB |
Output is correct |
28 |
Correct |
29 ms |
2504 KB |
Output is correct |
29 |
Correct |
54 ms |
2508 KB |
Output is correct |
30 |
Correct |
58 ms |
2504 KB |
Output is correct |
31 |
Correct |
20 ms |
2484 KB |
Output is correct |
32 |
Correct |
0 ms |
332 KB |
Output is correct |
33 |
Correct |
15 ms |
1484 KB |
Output is correct |
34 |
Correct |
25 ms |
2504 KB |
Output is correct |
35 |
Correct |
3 ms |
592 KB |
Output is correct |
36 |
Correct |
17 ms |
1468 KB |
Output is correct |
37 |
Correct |
21 ms |
2488 KB |
Output is correct |
38 |
Correct |
28 ms |
2456 KB |
Output is correct |
39 |
Correct |
12 ms |
1484 KB |
Output is correct |
40 |
Correct |
1 ms |
332 KB |
Output is correct |
41 |
Correct |
51 ms |
2400 KB |
Output is correct |
42 |
Correct |
31 ms |
2504 KB |
Output is correct |
43 |
Correct |
37 ms |
2408 KB |
Output is correct |
44 |
Correct |
30 ms |
2504 KB |
Output is correct |
45 |
Correct |
29 ms |
2440 KB |
Output is correct |
46 |
Correct |
60 ms |
2460 KB |
Output is correct |
47 |
Correct |
25 ms |
2448 KB |
Output is correct |
48 |
Correct |
34 ms |
2416 KB |
Output is correct |
49 |
Correct |
30 ms |
2460 KB |
Output is correct |
50 |
Correct |
192 ms |
2496 KB |
Output is correct |
51 |
Correct |
202 ms |
2504 KB |
Output is correct |
52 |
Correct |
191 ms |
2476 KB |
Output is correct |
53 |
Correct |
206 ms |
2504 KB |
Output is correct |
54 |
Correct |
198 ms |
2416 KB |
Output is correct |
55 |
Correct |
207 ms |
2424 KB |
Output is correct |
56 |
Correct |
178 ms |
2504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
24 ms |
1484 KB |
Output is correct |
10 |
Correct |
6 ms |
976 KB |
Output is correct |
11 |
Correct |
13 ms |
1484 KB |
Output is correct |
12 |
Correct |
12 ms |
1436 KB |
Output is correct |
13 |
Correct |
17 ms |
1420 KB |
Output is correct |
14 |
Correct |
13 ms |
1532 KB |
Output is correct |
15 |
Correct |
2 ms |
460 KB |
Output is correct |
16 |
Correct |
11 ms |
1484 KB |
Output is correct |
17 |
Correct |
28 ms |
2400 KB |
Output is correct |
18 |
Correct |
16 ms |
1484 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
0 ms |
336 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
0 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
332 KB |
Output is correct |
30 |
Correct |
0 ms |
332 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
7 ms |
976 KB |
Output is correct |
35 |
Correct |
23 ms |
2500 KB |
Output is correct |
36 |
Correct |
29 ms |
2504 KB |
Output is correct |
37 |
Correct |
54 ms |
2508 KB |
Output is correct |
38 |
Correct |
58 ms |
2504 KB |
Output is correct |
39 |
Correct |
20 ms |
2484 KB |
Output is correct |
40 |
Correct |
0 ms |
332 KB |
Output is correct |
41 |
Correct |
15 ms |
1484 KB |
Output is correct |
42 |
Correct |
25 ms |
2504 KB |
Output is correct |
43 |
Correct |
3 ms |
592 KB |
Output is correct |
44 |
Correct |
17 ms |
1468 KB |
Output is correct |
45 |
Correct |
21 ms |
2488 KB |
Output is correct |
46 |
Correct |
28 ms |
2456 KB |
Output is correct |
47 |
Correct |
12 ms |
1484 KB |
Output is correct |
48 |
Correct |
1 ms |
332 KB |
Output is correct |
49 |
Correct |
51 ms |
2400 KB |
Output is correct |
50 |
Correct |
31 ms |
2504 KB |
Output is correct |
51 |
Correct |
37 ms |
2408 KB |
Output is correct |
52 |
Correct |
30 ms |
2504 KB |
Output is correct |
53 |
Correct |
29 ms |
2440 KB |
Output is correct |
54 |
Correct |
60 ms |
2460 KB |
Output is correct |
55 |
Correct |
25 ms |
2448 KB |
Output is correct |
56 |
Correct |
34 ms |
2416 KB |
Output is correct |
57 |
Correct |
30 ms |
2460 KB |
Output is correct |
58 |
Correct |
192 ms |
2496 KB |
Output is correct |
59 |
Correct |
202 ms |
2504 KB |
Output is correct |
60 |
Correct |
191 ms |
2476 KB |
Output is correct |
61 |
Correct |
206 ms |
2504 KB |
Output is correct |
62 |
Correct |
198 ms |
2416 KB |
Output is correct |
63 |
Correct |
207 ms |
2424 KB |
Output is correct |
64 |
Correct |
178 ms |
2504 KB |
Output is correct |
65 |
Correct |
0 ms |
204 KB |
Output is correct |
66 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |