/*
I:
1. The path does not conatin layers.
Must compute:
1. the number of cells in the territory.
======================
======================
3 1 1
1 1
3 1
5 1
ans: 3 + 2*1 = 5
3 1 2
1 1
3 1
5 1
ans: 7
*/
#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define pb push_back
#define sz(x) ((int)x.size())
#define sp ' '
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define rep(i,x,n) for(int i=x; i<=n; ++i)
#define For(i,n) rep(i,0,n-1)
#define ff first
#define ss second
#define ld long double
#define mp make_pair
const ll mxN=6e5+10,OO=2e9,mod=1e9+7;
ll exp(ll b,ll p){
ll res=1;
while(p>0){
if(p&1)res=res*b%mod;
b=b*b%mod;
p/=2;
}
return res;
}
const ll inv=exp(6,mod-2);
const int dx[]{0,0,-1,1}, dy[]{1,-1,0,0};
void cmn(int &a,int b){a = min(a,b);}
void cmx(int &a,int b){a = max(a,b);}
int draw_territory(int N, int A, int B,vi D, vi L){
ll v=max(L[0],L[1]),ans=v+1,c=v+1;
c = c * (c+1)/2; ans = c * A %mod;
if(B){
// c= v*(v+1)*(2*v+1)/6;
c = (v*(v+1)%mod) * (2*v+1) % mod * inv % mod;
c += v*(v+1)/2; c%=mod;
ans += c*B % mod; ans %=mod;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |