#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define arr array
#define vct vector
#define pll pair<lint, lint>
#define fir first
#define sec second
const lint MD = 1e9 + 7, INV = 500000004;
lint md(lint x) { return (x + MD) % MD; }
lint gt_bnd(int n, vct<int> lng) {
lint ans = 0;
for (int i = 0; i < n; i++) ans += lng[i];
return ans;
}
pll mv(pll pt, lint drc, lint lng) {
pll dlt;
if (drc == 1) dlt = {0, 1};
if (drc == 2) dlt = {1, 1};
if (drc == 3) dlt = {1, 0};
if (drc == 4) dlt = {0, -1};
if (drc == 5) dlt = {-1, -1};
if (drc == 6) dlt = {-1, 0};
return {pt.fir + dlt.fir * lng, pt.sec + dlt.sec * lng};
}
vct<pll> gt_pts(int n, vct<int> drc, vct<int> lng) {
pll pt = {0, 0};
vct<pll> ans;
for (int i = 0; i < n; i++) {
pt = mv(pt, drc[i], lng[i]);
ans.push_back(pt);
}
return ans;
}
lint gt_tw_ar(vct<pll> pt) { // 2 * area to avoid floats
lint ans = 0;
for (int i = 0; i < pt.size(); i++) {
int j = (i + 1) % pt.size();
lint inc_ans = ((pt[i].fir - pt[j].fir) * (pt[i].sec + pt[j].sec));
ans += inc_ans;
}
ans = abs(ans);
return ans;
}
int draw_territory(int n, int a, int b, vct<int> drc, vct<int> lng) {
assert(b == 0);
lint bnd = gt_bnd(n, lng);
lint tw_ar = gt_tw_ar(gt_pts(n, drc, lng));
lint tw_ins = tw_ar - bnd + 2;
assert(tw_ins % 2 == 0);
lint ans = md(tw_ins / 2 + bnd);
ans = md(a * ans);
return ans;
}
Compilation message
hexagon.cpp: In function 'long long int gt_tw_ar(std::vector<std::pair<long long int, long long int> >)':
hexagon.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int i = 0; i < pt.size(); i++) {
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
436 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
428 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
2 ms |
1056 KB |
Output is correct |
7 |
Correct |
4 ms |
1748 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
5 ms |
2840 KB |
Output is correct |
12 |
Correct |
8 ms |
2960 KB |
Output is correct |
13 |
Correct |
5 ms |
2848 KB |
Output is correct |
14 |
Correct |
6 ms |
2956 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
1056 KB |
Output is correct |
9 |
Correct |
4 ms |
1752 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
2840 KB |
Output is correct |
14 |
Correct |
8 ms |
2964 KB |
Output is correct |
15 |
Correct |
5 ms |
2832 KB |
Output is correct |
16 |
Correct |
7 ms |
2956 KB |
Output is correct |
17 |
Correct |
1 ms |
444 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
11 ms |
4968 KB |
Output is correct |
21 |
Correct |
2 ms |
860 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
14 ms |
6096 KB |
Output is correct |
24 |
Correct |
22 ms |
10672 KB |
Output is correct |
25 |
Correct |
22 ms |
11148 KB |
Output is correct |
26 |
Correct |
11 ms |
5656 KB |
Output is correct |
27 |
Correct |
8 ms |
3616 KB |
Output is correct |
28 |
Correct |
9 ms |
2856 KB |
Output is correct |
29 |
Correct |
25 ms |
11588 KB |
Output is correct |
30 |
Correct |
25 ms |
11324 KB |
Output is correct |
31 |
Correct |
27 ms |
11328 KB |
Output is correct |
32 |
Correct |
27 ms |
11224 KB |
Output is correct |
33 |
Correct |
14 ms |
5604 KB |
Output is correct |
34 |
Correct |
8 ms |
2844 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
428 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |