# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934682 | MinaRagy06 | Hexagonal Territory (APIO21_hexagon) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef MINA
#include "grader.cpp"
#endif
#include "hexagon.h"
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
int draw_territory(int n, int a, int b, vector<int> d, vector<int> l) {
ll sz = l[0] + 1;
ll v1 = 1ll * sz * (sz + 1) / 2 % mod * a % mod;
v2 = 0;
if ((sz - 1) % 3 == 0) {
v2 = (sz - 1) / 3;
v2 = 1ll * v2 * sz % mod * (sz + 1) % mod;
} else if (sz % 3 == 0) {
v2 = sz / 3;
v2 = 1ll * v2 * (sz - 1) % mod * (sz + 1) % mod;
} else {
v2 = (sz + 1) / 3;
v2 = 1ll * v2 * (sz - 1) % mod * sz % mod;
}
v2 = 1ll * v2 * b % mod;
return (v1 + v2) % mod;
}