#include "hexagon.h"
#include <vector>
#include <unordered_set>
#include <queue>
long long mod = 1000000007;
using namespace std;
int draw_territory(int N, int A, int B, std::vector<int> D, std::vector<int> L){
int n = 2500;
vector<vector<int>> G(n*n);
int pos = 1200*n+1200;
unordered_set<int> s;
vector<int> C = {0,n,n+1,1,-n,-n-1,-1};
for(int i=0;i<N;i++){
for(int j=0;j<L[i];j++){
pos += C[D[i]];
s.insert(pos);
}
}
for(int i=0;i<n;i++)for(int j=0;j<n;j++){
if(i != 0) G[i*n+j].push_back((i-1)*n+j);
if(i < n-1) G[i*n+j].push_back((i+1)*n+j);
if(j != 0) G[i*n+j].push_back(i*n+j-1);
if(j < n-1) G[i*n+j].push_back(i*n+j+1);
if(i != 0 && j != 0) G[i*n+j].push_back((i-1)*n+(j-1));
if(i < n-1 && j < n-1) G[i*n+j].push_back((i+1)*n+(j+1));
}
vector<int> dist(n*n,1e9);
dist[pos] = 0;
queue<int> q;
q.push(pos);
while(!q.empty()){
int po = q.front();
q.pop();
for(int x:G[po]){
if(dist[x] != 1e9) continue;
if(!s.count(x)) q.push(x);
dist[x] = dist[po] + 1;
}
}
long long ans = 0;
for(int x:dist) ans += x;
return ans%mod;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2112 ms |
813888 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2078 ms |
813972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1843 ms |
464916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1951 ms |
473780 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2068 ms |
564728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1954 ms |
464928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2076 ms |
585532 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1995 ms |
464832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |