Advertisement
Korotkodul

N3. Формальный исполнитель

Nov 24th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <set>
  5. #include <string>
  6. #include <algorithm>
  7. using namespace std;
  8. using ll = long long;
  9. void cv(vector <int> v){
  10. for (auto x: v) cout<<x<<' ';
  11. cout<<'\n';
  12. }
  13.  
  14. vector <ll> dx = {-1, 1, 0, 0};
  15. vector <ll> dy = {0,0,1,-1};
  16. vector <ll> cmd = {2, 1, 3, 0, 3, 1};
  17. ll sz = cmd.size();
  18. //up, down, R, L
  19.  
  20. //перегородки
  21. vector <pair <ll, ll> > bdX(6, {100, 100});
  22. vector <pair <ll, ll> > bdY(6, {100, 100});
  23.  
  24. bool bnd(ll x, ll y){//bound
  25. return x >= 0 && x < 6 && y >= 0 && y < 6;
  26. }
  27.  
  28. bool free(ll x, ll y, ll x1, ll y1){
  29. bool can = 1;
  30. if (x == x1){
  31. //cout<<"ONE\n";
  32. if (bdX[x].first == min(y, y1) && bdX[x].second == max(y, y1)){
  33. //cout<<"THREE\n";
  34. can = 0;
  35. }
  36. }
  37. else if (y == y1){
  38. //cout<<"TWO\n";
  39. if (bdY[y].first == min(x, x1) && bdY[y].second == max(x, x1)){
  40. //cout<<"FOUR\n";
  41. can = 0;
  42. }
  43. }
  44. //cout<<"free = "<<can<<"\n";
  45. return can;
  46. }
  47. ll ans = 0;
  48. vector <pair <ll, ll> > good;
  49. bool gd(ll x, ll y, ll x1, ll y1){
  50. bool can = 0;
  51. return free(x, y, x1, y1) && bnd(x1, y1);
  52. }
  53. bool sh = 0;
  54. void go(ll x, ll y){
  55. ll x1 = x, y1 = y;
  56. ll cnt = 0;
  57. while (cnt < sz){
  58. //if (sh) cout<<x<<' '<<y<<'\n';
  59. ll dir = cmd[cnt];
  60. while (gd(x, y, x + dx[dir], y + dy[dir])){
  61.  
  62. x += dx[dir];
  63. y += dy[dir];
  64. }
  65. cnt++;
  66. }
  67. if (x == 3 && y == 1){
  68. ans++;
  69. //good.push_back({x1, y1});
  70. }
  71. //if (sh) cout<<"\n\n";
  72. }
  73.  
  74.  
  75.  
  76. int main()
  77. {
  78. /*ios::sync_with_stdio(0);
  79. cin.tie(0);
  80. cout.tie(0);*/
  81. bdX[0] = {0,1};
  82. bdX[1] = {0,1};
  83. bdX[2] = {2,3};
  84. bdX[3] = {1,2};
  85.  
  86. bdY[1] = {3,4};
  87. bdY[3] = {2,3};
  88. bdY[5] = {2,3};
  89.  
  90. ll x0 = 3, y0 = 1;
  91. for (int i = 0; i < 6;++i){
  92. for (int j=0;j<6;++j){
  93. go(i, j);
  94. }
  95. }
  96. cout<<"ans= "<<ans<<"\n";
  97. /*sh = 1;
  98. for (auto g: good){
  99. //cout<<g.first<<' '<<g.second<<'\n';
  100. go(g.first, g.second);
  101. }*/
  102. }
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement