Guest User

Untitled

a guest
May 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3.  
  4. using namespace std;
  5.  
  6. class Point {
  7. public:
  8. int x, y;
  9. Point(int _x, int _y) {
  10. x = _x;
  11. y = _y;
  12. }
  13. };
  14.  
  15. int main() {
  16. int n;
  17. cin >> n;
  18.  
  19. //오른쪽, 위, 왼쪽, 아래
  20. int dx[] = { 1, 0, -1, 0 };
  21. int dy[] = { 0, -1, 0, 1 };
  22.  
  23. bool arr[101][101] = { false };
  24. //배열 채우기
  25. for (int t = 0; t < n; t++) {
  26. vector<int> direction;
  27. int x, y, d, g;
  28. cin >> x >> y >> d >> g;
  29.  
  30. direction.push_back(d);
  31. arr[x][y] = true;
  32. arr[x + dx[d]][y + dy[d]] = true;
  33. Point last = Point(x + dx[d], y + dy[d]);// 마지막 지점
  34.  
  35. while (g--) {
  36. int size = direction.size();//시계방향으로 돌릴 드래곤 개수
  37. int mul = 1;
  38. bool isLeft = true;//왼쪽인가, 오른쪽인가
  39.  
  40. for (int i = size - 1; i >= 0; i-=mul) {
  41. for (int j = i; j > i - mul; j--) {
  42. int nd = direction[i];
  43. if (isLeft) nd = (nd + 1) % 4;
  44. else nd = (nd - 1 + 4) % 4;
  45.  
  46. int nx = last.x + dx[nd];
  47. int ny = last.y + dy[nd];
  48. arr[nx][ny] = true;
  49. direction.push_back(nd);
  50.  
  51. //last 갱신
  52. last = Point(nx, ny);
  53. }
  54. mul *-2;
  55. isLeft != isLeft;
  56. }
  57. }
  58.  
  59. }
  60.  
  61. //정답 확인
  62. int ans = 0;
  63.  
  64. for (int i = 0; i < 100; i++) {
  65. for (int j = 0; j < 100; j++) {
  66. if (arr[i][j] && arr[i + 1][j] && arr[i][j + 1] && arr[i + 1][j + 1])
  67. ans++;
  68. }
  69. }
  70.  
  71. cout << ans;
  72. return 0;
  73. }
Add Comment
Please, Sign In to add comment