Submission #737451

# Submission time Handle Problem Language Result Execution time Memory
737451 2023-05-07T08:11:01 Z keisuke6 Hexagonal Territory (APIO21_hexagon) C++14
0 / 100
2000 ms 813952 KB
#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<bool> seen(n*n,false);
  seen[0] = true;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int pos = q.front();
    q.pop();
    for(int x:G[pos]){
      if(seen[x] || s.count(x)) continue;
      q.push(x);
      seen[x] = true;
    }
  }
  int ans = n*n;
  for(bool p:seen) ans -= p;
  return (int)((long long)ans*A%1000000007);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2120 ms 813952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2091 ms 619260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1462 ms 441260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1323 ms 450052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2116 ms 813920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1520 ms 441356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2106 ms 813856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1428 ms 441228 KB Output isn't correct
2 Halted 0 ms 0 KB -