#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
const pair<long long, long long> dir[7]={{0, 0}, {1, 0}, {0, 1}, {-1, 1}, {-1, 0}, {0, -1}, {1, -1}};
const long long mod=1000000007;
long long border[2005][2005], outside[2005][2005], dist[2005][2005];
queue<pair<long long, long long> > q;
vector<long long> d, l;
int draw_territory(int nn, int aa, int bb, vector<int> dd, vector<int> ll)
{
long long n=nn, a=aa, b=bb, curX=1000, curY=1000, ans=0;
for (long long i=0; i<n; i++)
d.push_back(dd[i]), l.push_back(ll[i]);
for (long long i=0; i<n; i++)
{
for (long long j=0; j<l[i]; j++)
{
curX+=dir[d[i]].first;
curY+=dir[d[i]].second;
border[curX][curY]=1;
}
}
outside[2000][2000]=1;
q.push({2000, 2000});
while (!q.empty())
{
long long ux=q.front().first, uy=q.front().second;
q.pop();
for (long long i=1; i<=6; i++)
{
long long vx=ux+dir[i].first, vy=uy+dir[i].second;
if (0<=vx && vx<=2000 && 0<=vy && vy<=2000 && !border[vx][vy] && !outside[vx][vy])
{
outside[vx][vy]=1;
q.push({vx, vy});
}
}
}
for (long long i=0; i<=2000; i++)
for (long long j=0; j<=2000; j++)
dist[i][j]=1e9;
dist[1000][1000]=0;
q.push({1000, 1000});
while (!q.empty())
{
long long ux=q.front().first, uy=q.front().second;
q.pop();
ans=(ans+a+dist[ux][uy]*b)%mod;
for (long long i=1; i<=6; i++)
{
long long vx=ux+dir[i].first, vy=uy+dir[i].second;
if (!outside[vx][vy] && dist[ux][uy]+1<dist[vx][vy])
{
dist[vx][vy]=dist[ux][uy]+1;
q.push({vx, vy});
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
111 ms |
159836 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
122 ms |
159820 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
63204 KB |
Output is correct |
2 |
Correct |
125 ms |
65032 KB |
Output is correct |
3 |
Correct |
121 ms |
64432 KB |
Output is correct |
4 |
Correct |
120 ms |
64048 KB |
Output is correct |
5 |
Correct |
124 ms |
64988 KB |
Output is correct |
6 |
Correct |
145 ms |
63976 KB |
Output is correct |
7 |
Correct |
150 ms |
64264 KB |
Output is correct |
8 |
Correct |
140 ms |
63688 KB |
Output is correct |
9 |
Correct |
152 ms |
63428 KB |
Output is correct |
10 |
Correct |
142 ms |
63452 KB |
Output is correct |
11 |
Correct |
142 ms |
63688 KB |
Output is correct |
12 |
Correct |
143 ms |
66228 KB |
Output is correct |
13 |
Correct |
143 ms |
66252 KB |
Output is correct |
14 |
Correct |
144 ms |
66160 KB |
Output is correct |
15 |
Correct |
133 ms |
64164 KB |
Output is correct |
16 |
Correct |
138 ms |
63416 KB |
Output is correct |
17 |
Correct |
146 ms |
63504 KB |
Output is correct |
18 |
Correct |
128 ms |
67332 KB |
Output is correct |
19 |
Correct |
140 ms |
67276 KB |
Output is correct |
20 |
Correct |
123 ms |
63088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
56 ms |
41348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
120 ms |
159744 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
63200 KB |
Output is correct |
2 |
Correct |
143 ms |
65184 KB |
Output is correct |
3 |
Correct |
153 ms |
64368 KB |
Output is correct |
4 |
Correct |
140 ms |
63944 KB |
Output is correct |
5 |
Correct |
132 ms |
65000 KB |
Output is correct |
6 |
Correct |
132 ms |
63940 KB |
Output is correct |
7 |
Correct |
135 ms |
64388 KB |
Output is correct |
8 |
Correct |
133 ms |
63712 KB |
Output is correct |
9 |
Correct |
177 ms |
63452 KB |
Output is correct |
10 |
Correct |
133 ms |
63448 KB |
Output is correct |
11 |
Correct |
167 ms |
63768 KB |
Output is correct |
12 |
Correct |
128 ms |
66184 KB |
Output is correct |
13 |
Correct |
133 ms |
66252 KB |
Output is correct |
14 |
Correct |
135 ms |
66220 KB |
Output is correct |
15 |
Correct |
137 ms |
64272 KB |
Output is correct |
16 |
Correct |
130 ms |
63332 KB |
Output is correct |
17 |
Correct |
128 ms |
63528 KB |
Output is correct |
18 |
Runtime error |
62 ms |
41256 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
123 ms |
159860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
63172 KB |
Output is correct |
2 |
Runtime error |
120 ms |
159872 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |