Submission #440434

#TimeUsernameProblemLanguageResultExecution timeMemory
440434sam571128Hexagonal Territory (APIO21_hexagon)C++17
30 / 100
55 ms7784 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) { 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 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...