Advertisement
Korotkodul

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

Nov 24th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 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. vector <int> dx = {-1, -1, 0, 1, 1, 1, 0, -1};
  14. vector <int> dy = {0, 1, 1, 1, 0, -1, -1, -1};
  15. vector <vector <int> > dsk(8, vector <int> (8,0));
  16. vector <pair <int, int> > srt = {{0,2}, {1,3}, {2,1}, {2,2,}, {2,3} };
  17.  
  18. bool gd(int i, int j){
  19. return i >= 0 && i < 8 && j>=0 && j < 8;
  20. }
  21.  
  22. void al(){
  23. vector <vector <int> > hlf(8, vector <int> (8, -9));
  24. for (int I = 0; I < 8 ;++I){
  25. for (int J = 0; J < 8;++J){
  26. int bl = 0;
  27. for (int q = 0;q<8;++q){
  28. int X = I + dx[q];
  29. int Y = J + dy[q];
  30. if (gd(X,Y) && dsk[X][Y] == 1){
  31. bl++;
  32. }
  33. }
  34. if (dsk[I][J] == 0){
  35. if (bl==3){
  36. hlf[I][J] = 1;
  37. }
  38. else hlf[I][J] = 0;
  39.  
  40. }else {
  41. if (bl == 2 || bl == 3){
  42. hlf[I][J] = 1;
  43. }else hlf[I][J] = 0;
  44. }
  45. }
  46. }
  47. dsk = hlf;
  48. }
  49.  
  50. int main()
  51. {
  52. /*ios::sync_with_stdio(0);
  53. cin.tie(0);
  54. cout.tie(0);*/
  55. for (auto c: srt) dsk[c.first][c.second] = 1;
  56. for (int i = 0; i < 8;++i){
  57. for (int j=0;j<8;++j){
  58. cout<<dsk[i][j];
  59. }cout<<'\n';
  60. }cout<<"\n\n";
  61.  
  62. for (int i = 0;i<3;++i){
  63. al();
  64. for (int i = 0; i < 8;++i){
  65. for (int j=0;j<8;++j){
  66. cout<<dsk[i][j];
  67. }cout<<'\n';
  68. }cout<<"\n\n";
  69. }
  70. vector <pair<int,int> > ans;
  71. for (int i = 0; i < 8;++i){
  72. for (int j=0;j<8;++j){
  73. if (dsk[i][j]){
  74. ans.push_back({i,j});
  75. }
  76. }
  77. }
  78. string sh = "ABCDEFGH";
  79. for (auto f: ans) cout<<sh[f.second]<<f.first+1<<'\n';
  80.  
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement