Submission #440429

#TimeUsernameProblemLanguageResultExecution timeMemory
440429sam571128Hexagonal Territory (APIO21_hexagon)C++14
0 / 100
1 ms204 KiB
#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) { int 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) nowy += L[i-1]; if(D[i]==2) nowx += L[i-1], nowy += L[i-1]; if(D[i]==3) nowx += L[i-1]; if(D[i]==4) nowy -= L[i-1]; if(D[i]==5) nowx -= L[i-1], nowy -= L[i-1]; if(D[i]==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 ans*A%MOD; } //Subtask: B=0 => count the area
#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...