Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <string>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- void cv(vector <int> v){
- for (auto x: v) cout<<x<<' ';
- cout<<'\n';
- }
- vector <int> dx = {-1, -1, 0, 1, 1, 1, 0, -1};
- vector <int> dy = {0, 1, 1, 1, 0, -1, -1, -1};
- vector <vector <int> > dsk(8, vector <int> (8,0));
- vector <pair <int, int> > srt = {{0,2}, {1,3}, {2,1}, {2,2,}, {2,3} };
- bool gd(int i, int j){
- return i >= 0 && i < 8 && j>=0 && j < 8;
- }
- void al(){
- vector <vector <int> > hlf(8, vector <int> (8, -9));
- for (int I = 0; I < 8 ;++I){
- for (int J = 0; J < 8;++J){
- int bl = 0;
- for (int q = 0;q<8;++q){
- int X = I + dx[q];
- int Y = J + dy[q];
- if (gd(X,Y) && dsk[X][Y] == 1){
- bl++;
- }
- }
- if (dsk[I][J] == 0){
- if (bl==3){
- hlf[I][J] = 1;
- }
- else hlf[I][J] = 0;
- }else {
- if (bl == 2 || bl == 3){
- hlf[I][J] = 1;
- }else hlf[I][J] = 0;
- }
- }
- }
- dsk = hlf;
- }
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- for (auto c: srt) dsk[c.first][c.second] = 1;
- for (int i = 0; i < 8;++i){
- for (int j=0;j<8;++j){
- cout<<dsk[i][j];
- }cout<<'\n';
- }cout<<"\n\n";
- for (int i = 0;i<3;++i){
- al();
- for (int i = 0; i < 8;++i){
- for (int j=0;j<8;++j){
- cout<<dsk[i][j];
- }cout<<'\n';
- }cout<<"\n\n";
- }
- vector <pair<int,int> > ans;
- for (int i = 0; i < 8;++i){
- for (int j=0;j<8;++j){
- if (dsk[i][j]){
- ans.push_back({i,j});
- }
- }
- }
- string sh = "ABCDEFGH";
- for (auto f: ans) cout<<sh[f.second]<<f.first+1<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement