#include <iostream>
using namespace std;
int dx[4] = {-1,0,1,1};
int dy[4] = {1,1,0,1};

int main() {
    int arr[20][20];
    for (int i = 0;i < 19;i++) {
        for (int j = 0;j < 19;j++) {
            cin >> arr[i][j];
        //    cout << arr[i][j] << " ";
        }
      //  cout << "\n";
    }

    int cnt = 0;
    for (int i = 0;i < 19;i++) {
        for (int j = 0;j < 19;j++) {
            if (arr[i][j] == 1) {
        //        cout << i << " " << j << "\n";
           //     visited[i][j] == 1;
                //OK
                //cout << 0;
                int nx = i;
                int ny = j;
                for (int b = 0;b < 4;b++) {
                    nx = i+dx[b];
                    ny = j+dy[b];
               //     cout << b<< "\n";
                 //   if (nx+dx[b] >= 0 && nx+dx[b] < 19 && ny+dy[b] >= 0 && ny+dy[b] < 19){
                   // if (arr[nx-dx[b]][ny-dy[b]] != 1) 
                    {    
                    while(arr[nx][ny] == 1) {//cout << i <<" "<< j << " " << b << " " << cnt << " " << ny << " " << nx << "\n"; 
                       //    cout << cnt << " " <<i<<" " << j<<" " << b<<" "<<nx << " " << ny << "\n";
                        //    if (visited[ny][nx] == 0) {
                    //            visited[nx][ny] = 1;
                              //  if (arr[nx-dx[b]][ny-dy[b]] != 1) {
                                    cnt++;
                                    nx = nx+dx[b];
                                    ny = ny+dy[b];
                            //    }
                            //    visited[nx][ny] = 1;
                            
                          //      cout << cnt << " " <<i<<" " << j<<" "<<nx << " " << ny << "\n";
                         //   }
                        }
                    }
                    
                    if (cnt == 4 && arr[i-dx[b]][j-dy[b]] != 1) {
                        //cout << 0;
                        cout << 1 << "\n";
                        cout << i+1 << " " << j+1;
                        return 0;
                    }
                  //  }
                    
              //      cout << cnt << " " << nx << " " << ny << "\n";
                    cnt = 0;
                }
            }
            
            if (arr[i][j] == 2) {
             //   visited[i][j] == 1;
                
                //cout << i << " " << j << "\n";
                int nx = i;
                int ny = j;
                for (int b = 0;b < 4;b++) {
                    nx = i+dx[b];
                    ny = j+dy[b];
                    while(arr[nx][ny] == 2) {
                      //  if (nx+dx[b] >= 0 && nx+dx[b] < 19 &&ny+dy[b] >= 0 &&ny+dy[b] < 19) {
                            cnt++;
             //           visited[nx][ny] = 1;
                            nx = nx+dx[b];
                            ny = ny+dy[b];
                     //   }
                    }
                    if (cnt == 4 && arr[i-dx[b]][j-dy[b]] != 2) {
                        cout << 2 << "\n";
                        cout << i+1 << " " << j+1; 
                        return 0;
                    }
                    cnt = 0;
                }
            }
        }
    }
    cout << 0;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: