#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll nx=2505, mod=1e9+7;
ll a, b, k, cnt, dp[nx][nx], x, y, dx[]={1, -1, 0, 0, 1, -1}, dy[]={0, 0, 1, -1, -1, 1}, res, used[nx][nx];
bool vs[nx][nx];
int draw_territory(int N, int A, int B, std::vector<int> D, std::vector<int> L) {
a=A, b=B;
x=1200, y=1200;
vs[x][y]=1;
for (int i=0; i<N; i++)
{
if (D[i]==1)
{
while (L[i]--) y++, vs[x][y]=1;
}
if (D[i]==2)
{
while (L[i]--) x++, vs[x][y]=1;
}
if (D[i]==3)
{
while (L[i]--) x++, y--, vs[x][y]=1;
}
if (D[i]==4)
{
while (L[i]--) y--, vs[x][y]=1;
}
if (D[i]==5)
{
while (L[i]--) x--, vs[x][y]=1;
}
if (D[i]==6)
{
while (L[i]--) x--, y++, vs[x][y]=1;
}
}
queue<pair<int, int>> q;
q.push({0, 0});
used[0][0]=1;
while (!q.empty())
{
auto [x, y]=q.front();
q.pop();
for (int i=0; i<6; i++)
{
int cx=x+dx[i], cy=y+dy[i];
if (cx<0||cy<0||cx>=nx||cy>=nx||vs[cx][cy]||used[cx][cy]) continue;
used[cx][cy]=1;
q.push({cx, cy});
}
}
while (!q.empty()) q.pop();
for (int i=0;i <nx;i ++) for (int j=0; j<nx;j ++) if (!used[i][j]) vs[i][j]=1, cnt++;
//cout<<"cnt "<<cnt<<'\n';
res+=a;
q.push({1200, 1200});
vs[1200][1200]=0;
while (!q.empty())
{
auto [x, y]=q.front();
q.pop();
for (int i=0; i<6; i++)
{
int cx=x+dx[i], cy=y+dy[i];
if (!vs[cx][cy]) continue;
vs[cx][cy]=0;
dp[cx][cy]=dp[x][y]+1;
res=(res+a+b*dp[cx][cy])%mod;
q.push({cx, cy});
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
6492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
6492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
49440 KB |
Output is correct |
2 |
Correct |
153 ms |
52204 KB |
Output is correct |
3 |
Correct |
157 ms |
51028 KB |
Output is correct |
4 |
Correct |
151 ms |
51092 KB |
Output is correct |
5 |
Correct |
155 ms |
51796 KB |
Output is correct |
6 |
Correct |
146 ms |
50768 KB |
Output is correct |
7 |
Correct |
159 ms |
51084 KB |
Output is correct |
8 |
Correct |
142 ms |
50596 KB |
Output is correct |
9 |
Correct |
150 ms |
50004 KB |
Output is correct |
10 |
Correct |
153 ms |
49960 KB |
Output is correct |
11 |
Correct |
159 ms |
50260 KB |
Output is correct |
12 |
Correct |
148 ms |
53572 KB |
Output is correct |
13 |
Correct |
171 ms |
53844 KB |
Output is correct |
14 |
Correct |
151 ms |
54100 KB |
Output is correct |
15 |
Correct |
155 ms |
49616 KB |
Output is correct |
16 |
Correct |
187 ms |
50128 KB |
Output is correct |
17 |
Correct |
138 ms |
49748 KB |
Output is correct |
18 |
Correct |
163 ms |
55356 KB |
Output is correct |
19 |
Correct |
153 ms |
55380 KB |
Output is correct |
20 |
Correct |
144 ms |
49492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
123 ms |
159824 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
6332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
49568 KB |
Output is correct |
2 |
Correct |
172 ms |
52308 KB |
Output is correct |
3 |
Correct |
154 ms |
51028 KB |
Output is correct |
4 |
Correct |
148 ms |
50940 KB |
Output is correct |
5 |
Correct |
155 ms |
51796 KB |
Output is correct |
6 |
Correct |
172 ms |
50912 KB |
Output is correct |
7 |
Correct |
152 ms |
51284 KB |
Output is correct |
8 |
Correct |
141 ms |
50516 KB |
Output is correct |
9 |
Correct |
146 ms |
50004 KB |
Output is correct |
10 |
Correct |
170 ms |
50004 KB |
Output is correct |
11 |
Correct |
146 ms |
50240 KB |
Output is correct |
12 |
Correct |
150 ms |
53724 KB |
Output is correct |
13 |
Correct |
148 ms |
53736 KB |
Output is correct |
14 |
Correct |
148 ms |
54112 KB |
Output is correct |
15 |
Correct |
143 ms |
49616 KB |
Output is correct |
16 |
Correct |
155 ms |
50144 KB |
Output is correct |
17 |
Correct |
145 ms |
49748 KB |
Output is correct |
18 |
Runtime error |
120 ms |
159828 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
6504 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
49644 KB |
Output is correct |
2 |
Runtime error |
5 ms |
6504 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |