Submission #1097107

#TimeUsernameProblemLanguageResultExecution timeMemory
1097107gygHexagonal Territory (APIO21_hexagon)C++17
30 / 100
27 ms11588 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...