#include <bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define MASK(i) (1LL << (i))
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define forr(i,l,r,add) for(int i = l;i <= r; i = i + add)
#define fodd(i,l,r,sub) for(int i = l;i >= r ; i = i - sub)
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
using namespace std;
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
#define rand rd
long long Rand(long long l , long long h){
assert(l <= h);
return l + 1ll * rd() % (h - l + 1) * (rd() % (h - l + 1)) % (h - l + 1);
}
//////////////////////////////////////////////////////////// end of template ////////////////////////////////////////////////////////////
const int MAX = 2e5 + 5;
ii save[MAX];
int n;
int dx[6] = {0 , 1 , 1 , 0 , -1 , -1} , dy[6] = {1 , 0 , -1 , -1 , 0 , 1};
ll calc(ii x , ii y){
return 1ll * (y.fi - x.fi) * (x.se + y.se);
}
int draw_territory(int n, int A, int B, vector <int> kk, vector <int> kk2){
int num_I = 0;
forr(i , 1 , n , 1){
int d , l;
d = kk[i - 1] , l = kk2[i - 1];
num_I += l;
save[i].fi = save[i - 1].fi + dx[d - 1] * l;
save[i].se = save[i - 1].se + dy[d - 1] * l;
}
ll S = 0;
forr(i , 1 , n , 1){
S += calc(save[i - 1] , save[i]);
}
S = abs(S);
//cout << S << ' ' << num_I << endl;
S -= num_I - 2;
int MOD = 1e9 + 7;
return (S / 2 + num_I) % MOD;
}
/*int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#define TASK ""
//freopen(TASK".inp" , "r" , stdin);
//freopen(TASK".out" , "w" , stdout);
INP();
return 0;
}*/
| # | 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... |