| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 135 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
| Name |
|---|



include
include
using namespace std; queue < pair< int,int > > st; char a[101][101]; int dx[7] = {0, 1, -1, 0, 0 },dy[7] = {0,0,0,1,-1},n,m; bool used[101][101]; int main () { cin >> n >> m;
for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> a[i][j]; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) { if (!used[i][j]) { st.push(make_pair(i,j)); while(!st.empty()) { int x,y; x = st.front().first; y = st.front().second; st.pop(); if(used[x][y]) { cout<<"Yes"; return 0; } used[x][y] = 1; for(int t = 1; t <= 4; t++) { int ii,jj; ii = x + dx[t]; jj = y + dy[t]; if ( a[ii][jj] != a[x][y]) continue; if (!used[ii][jj]) st.push(make_pair(ii,jj)); } } } } cout <<"No";}