답안 #988974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988974 2024-05-27T07:47:01 Z vjudge1 육각형 영역 (APIO21_hexagon) C++17
11 / 100
399 ms 10332 KB
#include "hexagon.h"
#include <bits/stdc++.h>
#include <vector>
#define debu(x) (cerr << #x  << " = "<< x << "\n")
#define moddy 1000000007
#define ff first
#define pii pair<int,int>
#define piii pair<pii,int>
#define pb push_back
#define ss second
#define ll long long 
using namespace std;

/*bool bins(vector<bool> &chosen, pii cha)
{
	//cout << "inbins\n";
	if (cha.ff > 4000 || cha.ff < 0)return false;
	if (cha.ss > 8000 || cha.ss < 0) return false;
	return (chosen[cha.ff*10000+cha.ss]);
}*/


int draw_territory(int N, int A, int B, std::vector<int> D, std::vector<int> L)
{
  //cout << "in terr\n";
  #define int long long
  vector<pii>dir = {{0,2},{1,1},{1,-1},{0,-2},{-1,-1},{-1,1}};
  
  pii currat={2000,4000};
  vector<bool>chosen(40008001,1);
  chosen[20004000] = false;
  //cout << "ok";
  int path = 0;
  for (int a=0;a<N;a++)
  {
	  for (int b = 0; b<L[a];b++)
	  {
		  currat.ff += dir[D[a] - 1].ff;
		  currat.ss += dir[D[a] - 1].ss;
		  //cout << currat.ff*10000+currat.ss << "\n";
		  chosen[currat.ff*10000+currat.ss] = false;
		  path++;
	  }
  }
  //cout << path << "pathos\n";
  //cout << "can";
  queue<pii>tbc;
  vector<vector<bool>>grid(4001,vector<bool>(8001,1));
  tbc.push({4000,8002});
  //grid[2000][4000] = false;
  
  while(!tbc.empty())
  {
	  pii current = tbc.front();
	  //cout << current.ff << " " << current.ss << "\n";
	  tbc.pop();
	  
	  for (pii xx : dir)
	  {
		  if ((current.ff + xx.ff) >= 0 && (current.ff + xx.ff) <=4000 && (current.ss + xx.ss) >= 0 && (current.ss + xx.ss) <= 8000 && (chosen[(current.ff + xx.ff)*10000 + current.ss + xx.ss])&&(grid[current.ff + xx.ff][current.ss + xx.ss]))
		  {
			  tbc.push(make_pair(current.ff + xx.ff, current.ss + xx.ss));
			  grid[current.ff+ xx.ff][current.ss+ xx.ss] = false;
		  }
		  else continue;
	  }
  }
  int ans = 0;
  //cout << "exited out";
  
  //cout << "the ones we accepted:\n";
  int cour=0;
  map<int,int> xcom;
  queue<piii>tbf;
  tbf.push({{2000,4000},0});
  grid[2000][4000] = false;
  while (!tbf.empty())
  {
	  piii current = tbf.front();
	  //cout << current.ff.ff << " " << current.ff.ss << " : " << current.ss << "\n";
	  tbf.pop();
	  cour++;
	  ans += A;
	  ans%= moddy;
	  ans += current.ss * B;
	  ans %= moddy;
	  xcom[current.ss]+=1;
	  
	  for (pii xx : dir)
	  {
		  if ((current.ff.ff + xx.ff) >= 0 && (current.ff.ff + xx.ff) <=4000 && (current.ff.ss + xx.ss) >= 0 && (current.ff.ss + xx.ss) <= 8000 && (grid[current.ff.ff + xx.ff][current.ff.ss + xx.ss]))
		  {
			  tbf.push({make_pair(current.ff.ff + xx.ff, current.ff.ss + xx.ss),current.ss+1});
			  grid[current.ff.ff+ xx.ff][current.ff.ss+ xx.ss] = false;
		  }
		  else continue;
	  }
  }
  /*cout << "caroot:\n";
  for (auto x: xcom)
  {
	  cout << x.ff << " : " << x.ss << "\n";
  }
  cout << "kore " << cour << "\n";
  cout << ans << " ";*/
  #undef int 
  ans = ans%moddy;
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 10332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 10332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 9536 KB Output is correct
2 Correct 345 ms 9556 KB Output is correct
3 Correct 390 ms 9540 KB Output is correct
4 Correct 377 ms 9528 KB Output is correct
5 Correct 349 ms 9544 KB Output is correct
6 Correct 356 ms 9528 KB Output is correct
7 Correct 338 ms 9552 KB Output is correct
8 Correct 344 ms 9556 KB Output is correct
9 Correct 388 ms 9812 KB Output is correct
10 Correct 347 ms 9552 KB Output is correct
11 Correct 351 ms 9792 KB Output is correct
12 Correct 338 ms 9528 KB Output is correct
13 Correct 352 ms 9828 KB Output is correct
14 Correct 346 ms 9552 KB Output is correct
15 Correct 364 ms 9808 KB Output is correct
16 Correct 347 ms 9528 KB Output is correct
17 Correct 371 ms 9788 KB Output is correct
18 Correct 361 ms 9544 KB Output is correct
19 Correct 387 ms 9556 KB Output is correct
20 Correct 382 ms 9772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 10332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 10332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 395 ms 9556 KB Output is correct
2 Correct 331 ms 9528 KB Output is correct
3 Correct 367 ms 9544 KB Output is correct
4 Correct 341 ms 9544 KB Output is correct
5 Correct 345 ms 9528 KB Output is correct
6 Correct 392 ms 9524 KB Output is correct
7 Correct 393 ms 9544 KB Output is correct
8 Correct 355 ms 9548 KB Output is correct
9 Correct 352 ms 9556 KB Output is correct
10 Correct 350 ms 9556 KB Output is correct
11 Correct 343 ms 9556 KB Output is correct
12 Correct 338 ms 9548 KB Output is correct
13 Correct 359 ms 9552 KB Output is correct
14 Correct 328 ms 9544 KB Output is correct
15 Correct 399 ms 9556 KB Output is correct
16 Correct 333 ms 9552 KB Output is correct
17 Correct 364 ms 9524 KB Output is correct
18 Runtime error 5 ms 10332 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 10328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 363 ms 9528 KB Output is correct
2 Runtime error 5 ms 10328 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -