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 "hexagon.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int draw_territory(int N, int A, int B, vector<int> D, vector<int> L) {
ll x[N+1], y[N+1], nowx = 0, nowy = 0, MOD = 1e9+7, peri = 0;
x[0] = y[0] = 0;
for(int i = 1;i <= N;i++){
if(D[i-1]==1) nowy += L[i-1];
if(D[i-1]==2) nowx += L[i-1], nowy += L[i-1];
if(D[i-1]==3) nowx += L[i-1];
if(D[i-1]==4) nowy -= L[i-1];
if(D[i-1]==5) nowx -= L[i-1], nowy -= L[i-1];
if(D[i-1]==6) nowx -= L[i-1];
x[i] = nowx, y[i] = nowy;
peri = (peri+L[i-1])%MOD;
}
ll ans = 0;
for(int i = 0;i <= N;i++){
ans += x[i]*y[i+1]-x[i+1]*y[i];
}
ans = ((((abs(ans)-peri)/2 + 1)%MOD + MOD)%MOD + peri)%MOD;
return (int)(ans*A%MOD);
}
//Subtask: B=0 => count the area
# | 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... |