Guest User

Untitled

a guest
Oct 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <cstdio>
  2. #include<vector>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6.  
  7. int xx[4] = { 1,0,-1,0 };
  8. int yy[4] = { 0,-1,0,1 };
  9. int map[101][101] = { 0, };
  10. struct xy {
  11. int x;
  12. int y;
  13. xy() {}
  14. xy(int a, int b) {
  15. x = a;
  16. y = b;
  17. }
  18. };
  19.  
  20. struct curve {
  21. xy b; //begin
  22. xy e; //end
  23. int dir;
  24. int gen;
  25. curve() {}
  26. curve(int x, int y, int d, int g) {
  27. b.x = x;
  28. b.y = y;
  29. dir = d;
  30. gen = g;
  31. }
  32. void setend() {
  33. e.x = b.x + xx[dir];
  34. e.y = b.y + yy[dir];
  35. }
  36. void bydir() {
  37. int temp = -1 * b.y;
  38. b.y = b.x;
  39. b.x = temp;
  40. }
  41. void chk() {
  42. map[b.y][b.x] = 1;
  43. }
  44. };
  45.  
  46. int N, x, y, d, g;
  47. vector<curve> input, cv;
  48.  
  49.  
  50. void makecurve(curve start) {
  51. cv.clear();
  52. cv.resize(pow(2, start.gen));
  53. curve temp = start;
  54. temp.setend();
  55. cv[0] = temp;
  56. cv[0].chk();
  57. int i;
  58. for (int g = 0; g < start.gen; g++) {
  59. i = pow(2, g);
  60. for (int j = pow(2, g) - 1; j >= 0; j--) {
  61. temp = cv[j];
  62. temp.b = cv[i - 1].e;
  63. temp.dir = (temp.dir + 1) % 4;
  64. temp.setend();
  65. temp.chk();
  66. cv[i] = temp;
  67. i++;
  68. }
  69. }
  70. map[temp.e.y][temp.e.x] = 1;
  71. }
  72.  
  73.  
  74. int main() {
  75. scanf("%d", &N);
  76. for (int i = 0; i < N; i++) {
  77. scanf("%d%d%d%d", &x, &y, &d, &g);
  78. curve tmp(x, y, d, g);
  79. input.push_back(tmp);
  80. }
  81. for (int i = 0; i < N; i++) {
  82. makecurve(input[i]);
  83. }
  84.  
  85. int total = 0;
  86. for (int i = 0; i < 100; i++) {
  87. for (int j = 0; j < 100; j++) {
  88. if (map[i][j] == 1 && map[i + 1][j] == 1 && map[i][j + 1] == 1 && map[i + 1][j + 1] == 1)
  89. total++;
  90. }
  91. }
  92. printf("%d\n", total);
  93. return 0;
  94. }
Add Comment
Please, Sign In to add comment