#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define ldb long double
#define arr array
#define vct vector
#define pll pair<lint, lint>
#define fir first
#define sec second
lint gt_bnd(int n, vct<int> lng) {
int 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;
}
ldb gt_ar(vct<pll> pt) {
ldb ans = 0;
for (int i = 0; i < pt.size(); i++) {
int j = (i + 1) % pt.size();
ans += (ldb) (pt[i].fir - pt[j].fir) * (pt[i].sec + pt[j].sec) / 2;
}
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);
ldb ar = gt_ar(gt_pts(n, drc, lng));
lint ins = roundl(ar - (ldb) bnd / 2 + 1);
lint ans = ins + bnd;
return a * ans;
}
Compilation message
hexagon.cpp: In function 'long double gt_ar(std::vector<std::pair<long long int, long long int> >)':
hexagon.cpp:39: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]
39 | for (int i = 0; i < pt.size(); i++) {
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
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 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |