Submission #1097105

#TimeUsernameProblemLanguageResultExecution timeMemory
1097105gygHexagonal Territory (APIO21_hexagon)C++17
3 / 100
7 ms3056 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; } // No + MD lint gt_bnd(int n, vct<int> lng) { lint ans = 0; for (int i = 0; i < n; i++) ans = md(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 = md(md(pt[i].fir - pt[j].fir) * md(pt[i].sec + pt[j].sec)); ans = md(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 = md(tw_ar - bnd + 2); lint ans = md(md(tw_ins * INV) + 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...