text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; char a[10][10]; int main() { int flag = 0; for (int i = 3; i < 7; i++) { for (int j = 3; j < 7; j++) cin >> a[i][j]; } for (int i = 3; i < 7; i++) { for (int j = 3; j < 7; j++) { if ((a[i][j] == 'x' && a[i][j + 1] == 'x' && a[i][j + 2] == '.') || (a[i][j] == 'x' && a[i][j + 1] == '.' && a[i][j + 2] == 'x') || (a[i][j] == '.' && a[i][j + 1] == 'x' && a[i][j + 2] == 'x') || (a[i][j] == 'x' && a[i + 1][j] == 'x' && a[i + 2][j] == '.') || (a[i][j] == 'x' && a[i + 1][j] == '.' && a[i + 2][j] == 'x') || (a[i][j] == '.' && a[i + 1][j] == 'x' && a[i + 2][j] == 'x') || (a[i][j] == 'x' && a[i + 1][j + 1] == '.' && a[i + 2][j + 2] == 'x') || (a[i][j] == 'x' && a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == '.') || (a[i][j] == '.' && a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == 'x') || (a[i][j] == 'x' && a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == '.') || (a[i][j] == 'x' && a[i + 1][j - 1] == '.' && a[i + 2][j - 2] == 'x') || (a[i][j] == '.' && a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == 'x')) { flag = 1; break; } } if (flag == 1) break; } if (flag == 1) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; bool isPrime(long long a) { if (a == 1 || (a > 2 && a % 2 == 0)) return 0; for (long long i = 3; i * i <= a; i += 2) if (a % i == 0) return 0; return 1; } long long save[999999]; char a[50][50]; long long b[99999]; int main() { char c; for (int i = 10; i < 14; i++) { for (int j = 10; j < 14; j++) { cin >> a[i][j]; } } for (int i = 10; i < 14; i++) { for (int j = 10; j < 14; j++) { if (a[i][j] == '.') { a[i][j] = 'x'; for (int k = 10; k < 14; k++) { for (int q = 10; q < 14; q++) { if (a[k][q] == 'x' && a[k + 1][q] == 'x' && a[k + 2][q] == 'x') { cout << "YES"; return 0; } if (a[k][q] == 'x' && a[k][q + 1] == 'x' && a[k][q + 2] == 'x') { cout << "YES"; return 0; } if (a[k][q] == 'x' && a[k + 1][q + 1] == 'x' && a[k + 2][q + 2] == 'x') { cout << "YES"; return 0; } if (a[k][q] == 'x' && a[k + 1][q - 1] == 'x' && a[k + 2][q - 2] == 'x') { cout << "YES"; return 0; } } } a[i][j] = '.'; } } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000 + 10, mod = 1000000007; int a[10][10]; char c; bool ch(int x, int y) { int num = 0; num += a[x][y]; if (x < 4) num += a[x + 1][y]; else num = -10; if (x < 3) num += a[x + 2][y]; else num = -10; if (num == 2) return 1; num = 0; num += a[x][y]; if (y < 4) num += a[x][y + 1]; else num = -10; if (y < 3) num += a[x][y + 2]; else num = -10; if (num == 2) return 1; num = 0; num += a[x][y]; if (x < 4 && y < 4) num += a[x + 1][y + 1]; else num = -10; if (x < 3 && y < 3) num += a[x + 2][y + 2]; else num = -10; if (num == 2) return 1; num = 0; num += a[x][y]; if (x > 1 && y < 4) num += a[x - 1][y + 1]; else num = -10; if (x > 2 && y < 3) num += a[x - 2][y + 2]; else num = -10; if (num == 2) return 1; return 0; } int32_t main() { ios::sync_with_stdio(0); cin.tie(); cout.tie(); for (int i = 1; i < 5; i++) { for (int j = 1; j < 5; j++) { cin >> c; if (c == 'x') a[i][j] = 1; else if (c == 'o') a[i][j] = -1; } } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (ch(i, j)) { return cout << "YES", 0; } } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; bool check(char data[][4], long long i, long long j) { bool res = false; if ((j - 1) >= 0 && (j - 2) >= 0) { long long cntx = 0, cntd = 0; if (data[i][j - 1] == 'x' || data[i][j - 2] == 'x') cntx++; if (data[i][j - 1] == '.' || data[i][j - 2] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((j + 1) < 4 && (j + 2) < 4) { long long cntx = 0, cntd = 0; if (data[i][j + 1] == 'x' || data[i][j + 2] == 'x') cntx++; if (data[i][j + 1] == '.' || data[i][j + 2] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((i - 1) >= 0 && (i - 2) >= 0) { long long cntx = 0, cntd = 0; if (data[i - 1][j] == 'x' || data[i - 2][j] == 'x') cntx++; if (data[i - 1][j] == '.' || data[i - 2][j] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((i + 1) < 4 && (i + 2) < 4) { long long cntx = 0, cntd = 0; if (data[i + 1][j] == 'x' || data[i + 2][j] == 'x') cntx++; if (data[i + 1][j] == '.' || data[i + 2][j] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((i - 2) >= 0 && (j - 2) >= 0) { long long cntx = 0, cntd = 0; if (data[i - 1][j - 1] == 'x' || data[i - 2][j - 2] == 'x') cntx++; if (data[i - 1][j - 1] == '.' || data[i - 2][j - 2] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((i + 2) < 4 && (j + 2) < 4) { long long cntx = 0, cntd = 0; if (data[i + 1][j + 1] == 'x' || data[i + 2][j + 2] == 'x') cntx++; if (data[i + 1][j + 1] == '.' || data[i + 2][j + 2] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((i + 2) < 4 && (j - 2) >= 0) { long long cntx = 0, cntd = 0; if (data[i + 1][j - 1] == 'x' || data[i + 2][j - 2] == 'x') cntx++; if (data[i + 1][j - 1] == '.' || data[i + 2][j - 2] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } if ((i - 2) >= 0 && (j + 2) < 4) { long long cntx = 0, cntd = 0; if (data[i - 1][j + 1] == 'x' || data[i - 2][j + 2] == 'x') cntx++; if (data[i - 1][j + 1] == '.' || data[i - 2][j + 2] == '.') cntd++; if (cntx == 1 && cntd == 1) return true; } return false; } int main() { long long i, j; char data[4][4]; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { cin >> data[i][j]; } } bool res = false; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (data[i][j] == 'x') { res = check(data, i, j); if (res == true) { cout << "YES" << endl; break; } } } if (res) break; } if (res == false) { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int Maxn = 2e6 + 5; char s[10][10]; int main() { int flag = 0; for (int i = 2; i <= 5; i++) scanf("%s", s[i] + 2); for (int i = 2; i <= 5; i++) { for (int j = 2; j <= 5; j++) { if (s[i][j] == 'x') { if (s[i - 1][j] == '.' && s[i - 2][j] == 'x') flag = 1; else if (s[i - 1][j] == 'x' && s[i - 2][j] == '.') flag = 1; else if (s[i + 1][j] == 'x' && s[i + 2][j] == '.') flag = 1; else if (s[i + 1][j] == '.' && s[i + 2][j] == 'x') flag = 1; else if (s[i][j - 1] == '.' && s[i][j - 2] == 'x') flag = 1; else if (s[i][j - 1] == 'x' && s[i][j - 2] == '.') flag = 1; else if (s[i][j + 1] == '.' && s[i][j + 2] == 'x') flag = 1; else if (s[i][j + 1] == 'x' && s[i][j + 2] == '.') flag = 1; else if (s[i + 1][j + 1] == '.' && s[i + 2][j + 2] == 'x') flag = 1; else if (s[i + 1][j + 1] == 'x' && s[i + 2][j + 2] == '.') flag = 1; else if (s[i - 1][j - 1] == '.' && s[i - 2][j - 2] == 'x') flag = 1; else if (s[i - 1][j - 1] == 'x' && s[i - 2][j - 2] == '.') flag = 1; else if (s[i + 1][j - 1] == '.' && s[i + 2][j - 2] == 'x') flag = 1; else if (s[i + 1][j - 1] == 'x' && s[i + 2][j - 2] == '.') flag = 1; else if (s[i - 1][j + 1] == '.' && s[i - 2][j + 2] == 'x') flag = 1; else if (s[i - 1][j + 1] == 'x' && s[i - 2][j + 2] == '.') flag = 1; } } } if (flag) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 10, inf = 0x3f3f3f3f; int a[N], l[N]; char s[10][10], x[10][10]; void get() { for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) { x[i][j] = s[i][j]; } } int main() { for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) { scanf(" %c", &s[i][j]); } for (int a = 1; a <= 4; a++) for (int b = 1; b <= 4; b++) { memset(x, 0, sizeof(x)); get(); if (x[a][b] == '.') { x[a][b] = 'x'; int yes = 0; for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) { if (x[i][j] == 'x') { if (x[i][j] == x[i + 1][j] && x[i - 1][j] == x[i][j]) yes = 1; if (x[i][j + 1] == x[i][j] && x[i][j - 1] == x[i][j]) yes = 1; if (x[i][j] == x[i - 1][j - 1] && x[i + 1][j + 1] == x[i][j]) yes = 1; if (x[i - 1][j + 1] == x[i][j] && x[i + 1][j - 1] == x[i][j]) yes = 1; } } if (yes) { puts("YES"); return 0; } } } puts("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; char Arr[4][4]; bool check(int i, int j) { if (j >= 2) { if (Arr[i][j - 1] == 'x' and Arr[i][j - 2] == 'x') return true; } if (j <= 1) { if (Arr[i][j + 1] == 'x' and Arr[i][j + 2] == 'x') return true; } if (i >= 2) { if (Arr[i - 1][j] == 'x' and Arr[i - 2][j] == 'x') return true; } if (i <= 1) { if (Arr[i + 1][j] == 'x' and Arr[i + 2][j] == 'x') return true; } if (i + 2 < 4 and j + 2 < 4) { if (Arr[i + 1][j + 1] == 'x' and Arr[i + 2][j + 2] == 'x') return true; } if (i - 2 >= 0 and j - 2 >= 0) { if (Arr[i - 1][j - 1] == 'x' and Arr[i - 2][j - 2] == 'x') return true; } if (i + 2 < 4 and j - 2 >= 0) { if (Arr[i + 1][j - 1] == 'x' and Arr[i + 2][j - 2] == 'x') return true; } if (j + 2 < 4 and i - 2 >= 0) { if (Arr[i - 1][j + 1] == 'x' and Arr[i - 2][j + 2] == 'x') return true; } if (i > 0 and j > 0 and i < 3 and j < 3) { if (Arr[i + 1][j + 1] == 'x' and Arr[i - 1][j - 1] == 'x') return true; if (Arr[i + 1][j - 1] == 'x' and Arr[i - 1][j + 1] == 'x') return true; } if (j > 0 and j < 3) { if (Arr[i][j + 1] == 'x' and Arr[i][j - 1] == 'x') return true; } if (i > 0 and i < 3) { if (Arr[i + 1][j] == 'x' and Arr[i - 1][j] == 'x') return true; } return false; } int main() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) cin >> Arr[i][j]; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (Arr[i][j] == '.') { if (check(i, j)) { cout << "YES" << endl; return 0; } } } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void print(vector<string> b) { for (long long int r = 0; r < 4; r++) cout << b[r] << endl; cout << endl; } bool check_row(vector<string> b) { for (long long int r = 0; r < 4; r++) { if ((b[r].substr(1, 3).compare("xxx") == 0) || (b[r].substr(0, 3).compare("xxx") == 0)) return true; } return false; } bool check_col(vector<string> b) { for (long long int c = 0; c < 4; c++) { string r02; r02 += b[0][c]; r02 += b[1][c]; r02 += b[2][c]; string r13; r13 += b[1][c]; r13 += b[2][c]; r13 += b[3][c]; if ((r02.compare("xxx") == 0) || (r13.compare("xxx") == 0)) return true; } return false; } bool check_diag(vector<string> b) { string d11; d11 += b[0][0]; d11 += b[1][1]; d11 += b[2][2]; string d12; d12 += b[1][1]; d12 += b[2][2]; d12 += b[3][3]; string d13; d13 += b[0][2]; d13 += b[1][1]; d13 += b[2][0]; string d14; d14 += b[1][3]; d14 += b[2][2]; d14 += b[3][1]; string d21; d21 += b[0][3]; d21 += b[1][2]; d21 += b[2][1]; string d22; d22 += b[1][2]; d22 += b[2][1]; d22 += b[3][0]; string d23; d23 += b[0][1]; d23 += b[1][2]; d23 += b[2][3]; string d24; d24 += b[1][0]; d24 += b[2][1]; d24 += b[3][2]; if ((d11.compare("xxx") == 0) || (d12.compare("xxx") == 0) || (d13.compare("xxx") == 0) || (d14.compare("xxx") == 0) || (d21.compare("xxx") == 0) || (d22.compare("xxx") == 0) || (d23.compare("xxx") == 0) || (d24.compare("xxx") == 0)) return true; return false; } bool check(vector<string> b) { return check_row(b) || check_col(b) || check_diag(b); } int main() { vector<string> a(4); for (long long int r = 0; r < 4; r++) { cin >> a[r]; } bool yes = false; for (long long int r = 0; r < 4; r++) { for (long long int c = 0; c < 4; c++) { if (a[r][c] == '.') { vector<string> b = a; b[r][c] = 'x'; if (check(b)) yes = true; } } } if (yes) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; bool win(int, int); string t[4]; int main() { bool isEmpty = true; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> t[i][j]; if (t[i][j] == 'x' || t[i][j] == 'o') isEmpty = false; } } if (isEmpty) { cout << "NO" << endl; return 0; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (t[i][j] == '.') { if (win(i, j)) { cout << "YES" << endl; return 0; } } } } cout << "NO" << endl; return 0; } bool win(int i, int j) { if (i - 1 >= 0 && i + 1 < 4) { if (t[i - 1][j] == 'x' && t[i + 1][j] == 'x') return true; } if (j - 1 >= 0 && j + 1 < 4) { if (t[i][j - 1] == 'x' && t[i][j + 1] == 'x') return true; } if ((i - 1 >= 0 && j - 1 >= 0) && (i + 1 < 4 && j + 1 < 4)) { if (t[i - 1][j - 1] == 'x' && t[i + 1][j + 1] == 'x') return true; } if ((i - 1 >= 0 && j + 1 >= 0) && (i + 1 < 4 && j - 1 < 4)) { if ((t[i - 1][j + 1] == 'x') && t[i + 1][j - 1] == 'x') return true; } if (j - 2 >= 0) { if (t[i][j - 1] == 'x' && t[i][j - 2] == 'x') return true; } if (j - 2 >= 0 && i + 2 < 4) { if (t[i + 1][j - 1] == 'x' && t[i + 2][j - 2] == 'x') return true; } if (i + 2 < 4) { if (t[i + 1][j] == 'x' && t[i + 2][j] == 'x') return true; } if (i + 2 < 4 && j + 2 < 4) { if (t[i + 1][j + 1] == 'x' && t[i + 2][j + 2] == 'x') return true; } if (j + 2 < 4) { if (t[i][j + 1] == 'x' && t[i][j + 2] == 'x') return true; } if (j + 2 < 4 && i - 2 >= 0) { if (t[i - 1][j + 1] == 'x' && t[i - 2][j + 2] == 'x') return true; } if (i - 2 >= 0) { if (t[i - 1][j] == 'x' && t[i - 2][j] == 'x') return true; } if (i - 2 >= 0 && j - 2 >= 0) { if (t[i - 1][j - 1] == 'x' && t[i - 2][j - 2] == 'x') return true; } return false; }
#include <bits/stdc++.h> using namespace std; int main() { char tab[4][4]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) scanf(" %c", &tab[i][j]); if ((tab[2][0] != 'o' && tab[1][1] != 'o' && tab[0][2] != 'o' && ((tab[2][0] == 'x' && tab[1][1] == 'x') || (tab[0][2] == 'x' && tab[2][0] == 'x') || (tab[1][1] == 'x' && tab[0][2] == 'x'))) || (tab[3][1] != 'o' && tab[2][2] != 'o' && tab[1][3] != 'o' && ((tab[3][1] == 'x' && tab[2][2] == 'x') || (tab[1][3] == 'x' && tab[3][1] == 'x') || (tab[2][2] == 'x' && tab[1][3] == 'x'))) || (tab[1][0] != 'o' && tab[2][1] != 'o' && tab[3][2] != 'o' && ((tab[1][0] == 'x' && tab[2][1] == 'x') || (tab[3][2] == 'x' && tab[1][0] == 'x') || (tab[2][1] == 'x' && tab[3][2] == 'x'))) || (tab[0][1] != 'o' && tab[1][2] != 'o' && tab[2][3] != 'o' && ((tab[0][1] == 'x' && tab[1][2] == 'x') || (tab[2][3] == 'x' && tab[0][1] == 'x') || (tab[1][2] == 'x' && tab[2][3] == 'x'))) || (tab[0][0] != 'o' && tab[1][1] != 'o' && tab[2][2] != 'o' && ((tab[0][0] == 'x' && tab[1][1] == 'x') || (tab[2][2] == 'x' && tab[0][0] == 'x') || (tab[1][1] == 'x' && tab[2][2] == 'x'))) || (tab[1][1] != 'o' && tab[2][2] != 'o' && tab[3][3] != 'o' && ((tab[1][1] == 'x' && tab[2][2] == 'x') || (tab[3][3] == 'x' && tab[1][1] == 'x') || (tab[2][2] == 'x' && tab[3][3] == 'x'))) || (tab[3][0] != 'o' && tab[2][1] != 'o' && tab[1][2] != 'o' && ((tab[3][0] == 'x' && tab[2][1] == 'x') || (tab[1][2] == 'x' && tab[3][0] == 'x') || (tab[2][1] == 'x' && tab[1][2] == 'x'))) || (tab[2][1] != 'o' && tab[1][2] != 'o' && tab[0][3] != 'o' && ((tab[2][1] == 'x' && tab[1][2] == 'x') || (tab[0][3] == 'x' && tab[2][1] == 'x') || (tab[1][2] == 'x' && tab[0][3] == 'x'))) || (tab[0][0] != 'o' && tab[0][1] != 'o' && tab[0][2] != 'o' && ((tab[0][0] == 'x' && tab[0][1] == 'x') || (tab[0][2] == 'x' && tab[0][0] == 'x') || (tab[0][1] == 'x' && tab[0][2] == 'x'))) || (tab[0][1] != 'o' && tab[0][2] != 'o' && tab[0][3] != 'o' && ((tab[0][1] == 'x' && tab[0][2] == 'x') || (tab[0][3] == 'x' && tab[0][1] == 'x') || (tab[0][2] == 'x' && tab[0][3] == 'x'))) || (tab[1][0] != 'o' && tab[1][1] != 'o' && tab[1][2] != 'o' && ((tab[1][0] == 'x' && tab[1][1] == 'x') || (tab[1][2] == 'x' && tab[1][0] == 'x') || (tab[1][1] == 'x' && tab[1][2] == 'x'))) || (tab[1][1] != 'o' && tab[1][2] != 'o' && tab[1][3] != 'o' && ((tab[1][1] == 'x' && tab[1][2] == 'x') || (tab[1][3] == 'x' && tab[1][1] == 'x') || (tab[1][2] == 'x' && tab[1][3] == 'x'))) || (tab[2][0] != 'o' && tab[2][1] != 'o' && tab[2][2] != 'o' && ((tab[2][0] == 'x' && tab[2][1] == 'x') || (tab[2][2] == 'x' && tab[2][0] == 'x') || (tab[2][1] == 'x' && tab[2][2] == 'x'))) || (tab[2][1] != 'o' && tab[2][2] != 'o' && tab[2][3] != 'o' && ((tab[2][1] == 'x' && tab[2][2] == 'x') || (tab[2][3] == 'x' && tab[2][1] == 'x') || (tab[2][2] == 'x' && tab[2][3] == 'x'))) || (tab[3][0] != 'o' && tab[3][1] != 'o' && tab[3][2] != 'o' && ((tab[3][0] == 'x' && tab[3][1] == 'x') || (tab[3][2] == 'x' && tab[3][0] == 'x') || (tab[3][1] == 'x' && tab[3][2] == 'x'))) || (tab[3][1] != 'o' && tab[3][2] != 'o' && tab[3][3] != 'o' && ((tab[3][1] == 'x' && tab[3][2] == 'x') || (tab[3][3] == 'x' && tab[3][1] == 'x') || (tab[3][2] == 'x' && tab[3][3] == 'x'))) || (tab[3][0] != 'o' && tab[2][0] != 'o' && tab[1][0] != 'o' && ((tab[3][0] == 'x' && tab[2][0] == 'x') || (tab[1][0] == 'x' && tab[3][0] == 'x') || (tab[2][0] == 'x' && tab[1][0] == 'x'))) || (tab[0][0] != 'o' && tab[1][0] != 'o' && tab[2][0] != 'o' && ((tab[0][0] == 'x' && tab[1][0] == 'x') || (tab[2][0] == 'x' && tab[0][0] == 'x') || (tab[1][0] == 'x' && tab[2][0] == 'x'))) || (tab[0][1] != 'o' && tab[1][1] != 'o' && tab[2][1] != 'o' && ((tab[0][1] == 'x' && tab[1][1] == 'x') || (tab[2][1] == 'x' && tab[0][1] == 'x') || (tab[1][1] == 'x' && tab[2][1] == 'x'))) || (tab[1][1] != 'o' && tab[2][1] != 'o' && tab[3][1] != 'o' && ((tab[1][1] == 'x' && tab[2][1] == 'x') || (tab[3][1] == 'x' && tab[1][1] == 'x') || (tab[2][1] == 'x' && tab[3][1] == 'x'))) || (tab[1][2] != 'o' && tab[2][2] != 'o' && tab[3][2] != 'o' && ((tab[1][2] == 'x' && tab[2][2] == 'x') || (tab[3][2] == 'x' && tab[1][2] == 'x') || (tab[2][2] == 'x' && tab[3][2] == 'x'))) || (tab[0][2] != 'o' && tab[1][2] != 'o' && tab[2][2] != 'o' && ((tab[0][2] == 'x' && tab[1][2] == 'x') || (tab[2][2] == 'x' && tab[0][2] == 'x') || (tab[1][2] == 'x' && tab[2][2] == 'x'))) || (tab[2][3] != 'o' && tab[1][3] != 'o' && tab[0][3] != 'o' && ((tab[2][3] == 'x' && tab[1][3] == 'x') || (tab[0][3] == 'x' && tab[2][3] == 'x') || (tab[1][3] == 'x' && tab[0][3] == 'x'))) || (tab[1][3] != 'o' && tab[2][3] != 'o' && tab[3][3] != 'o' && ((tab[3][3] == 'x' && tab[2][3] == 'x') || (tab[3][3] == 'x' && tab[1][3] == 'x') || (tab[2][3] == 'x' && tab[1][3] == 'x')))) printf("YES\n"); else printf("NO\n"); }
#include <bits/stdc++.h> using namespace std; char tab[10][10]; int bfs(int x, int y) { int i, j, mark; int a, b; int t = min(x, y) - 1; for (i = 1, mark = 0; i <= 4; i++) { if (tab[x][i] == 'x') { mark++; } else { mark = 0; } if (mark == 3) return 1; } for (i = 1, mark = 0; i <= 4; i++) { if (tab[i][y] == 'x') { mark++; } else { mark = 0; } if (mark == 3) return 1; } for (a = x, b = y; a > 0 && b > 0; a--, b--) { } for (i = a + 1, j = b + 1, mark = 0; i <= 4, j <= 4; i++, j++) { if (tab[i][j] == 'x') { mark++; } else { mark = 0; } if (mark == 3) return 1; } for (a = x, b = y; a > 0 && b < 5; a--, b++) { } for (i = a + 1, j = b - 1, mark = 0; i <= 1, j >= 1; i++, j--) { if (tab[i][j] == 'x') { mark++; } else { mark = 0; } if (mark == 3) return 1; } return 0; } int main() { int i, j; int mark = 0; for (i = 1; i <= 4; i++) { scanf("%s", tab[i] + 1); } for (i = 1; i <= 4; i++) { for (j = 1; j <= 4; j++) { if (tab[i][j] == '.') { tab[i][j] = 'x'; if (bfs(i, j)) { mark = 1; break; } tab[i][j] = '.'; } } if (mark) break; } if (mark) printf("YES\n"); else { printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 28; const long long LINF = 1ll << 61; char s[5][5]; int dx[4] = {1, 0, 1, -1}; int dy[4] = {0, 1, 1, 1}; bool check() { for (int i = 0; i <= 3; i++) for (int j = 0; j <= 3; j++) for (int d = 0; d < 4; d++) { bool ok = 1; for (int k = 0; k < 3; k++) { int nx = i + k * dx[d], ny = j + k * dy[d]; ok &= (nx < 4 && ny < 4 && nx >= 0 && ny >= 0 && s[nx][ny] == 'x'); } if (ok) return true; } return false; } int main() { for (int i = 0; i < 4; i++) scanf("%s", s[i]); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == '.') { s[i][j] = 'x'; if (check()) { puts("YES"); return 0; } s[i][j] = '.'; } } } puts("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; void printYes(vector<string> &data) { cout << "YES" << endl; } int main(int argc, const char *argv[]) { std::ios::sync_with_stdio(false); int n = 4; vector<string> data(n); for (int i = 0; i < n; ++i) cin >> data[i]; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 4; ++j) { if (data[i][j] == 'x' && data[i + 1][j] == 'x' && data[i + 2][j] == '.') { data[i + 2][j] = 'x'; printYes(data); return 0; } if (data[i][j] == 'x' && data[i + 1][j] == '.' && data[i + 2][j] == 'x') { data[i + 1][j] = 'x'; printYes(data); return 0; } if (data[i][j] == '.' && data[i + 1][j] == 'x' && data[i + 2][j] == 'x') { data[i][j] = 'x'; printYes(data); return 0; } } } for (int i = 0; i < 4; ++i) { for (int j = 0; j < 2; ++j) { if (data[i][j] == 'x' && data[i][j + 1] == 'x' && data[i][j + 2] == '.') { data[i][j + 2] = 'x'; printYes(data); return 0; } if (data[i][j] == 'x' && data[i][j + 1] == '.' && data[i][j + 2] == 'x') { data[i][j + 1] = 'x'; printYes(data); return 0; } if (data[i][j] == '.' && data[i][j + 1] == 'x' && data[i][j + 2] == 'x') { data[i][j] = 'x'; printYes(data); return 0; } } } for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { if (data[i][j] == 'x' && data[i + 1][j + 1] == 'x' && data[i + 2][j + 2] == '.') { data[i + 2][j + 2] = 'x'; printYes(data); return 0; } if (data[i][j] == 'x' && data[i + 1][j + 1] == '.' && data[i + 2][j + 2] == 'x') { data[i + 1][j + 1] = 'x'; printYes(data); return 0; } if (data[i][j] == '.' && data[i + 1][j + 1] == 'x' && data[i + 2][j + 2] == 'x') { data[i][j] = 'x'; printYes(data); return 0; } } } for (int i = 0; i < 2; ++i) { for (int j = 2; j < 4; ++j) { if (data[i][j] == 'x' && data[i + 1][j - 1] == 'x' && data[i + 2][j - 2] == '.') { data[i + 2][j - 2] = 'x'; printYes(data); return 0; } if (data[i][j] == 'x' && data[i + 1][j - 1] == '.' && data[i + 2][j - 2] == 'x') { data[i + 1][j - 1] = 'x'; printYes(data); return 0; } if (data[i][j] == '.' && data[i + 1][j - 1] == 'x' && data[i + 2][j - 2] == 'x') { data[i][j] = 'x'; printYes(data); return 0; } } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string a[4]; int main() { for (int i = 0; i < 4; i++) cin >> a[i]; bool ans = 0; for (int i = 2; i < 4; i++) { for (int j = 2; j < 4; j++) { if (a[i][j] == '.') { if (a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == 'x') { ans = 1; } } } } if (ans == 0) { for (int i = 2; i < 4; i++) { for (int j = 1; j >= 0; j--) { if (a[i][j] == '.') { if (a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == 'x') { ans = 1; } } } } } for (int i = 1; i >= 0; i--) { for (int j = 1; j >= 0; j--) { if (a[i][j] == '.') { if (a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == 'x') { ans = 1; } } } } if (ans == 0) { for (int i = 1; i >= 0; i--) { for (int j = 2; j < 4; j++) { if (a[i][j] == '.') { if (a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == 'x') { ans = 1; } } } } } if (ans == 0) { for (int i = 0; i < 4; i++) { for (int j = 2; j < 4; j++) { if (a[i][j] == '.') { if (a[i][j - 1] == 'x' && a[i][j - 2] == 'x') { ans = 1; } } } } } if (ans == 0) { for (int i = 0; i < 4; i++) { for (int j = 1; j >= 0; j--) { if (a[i][j] == '.') { if (a[i][j + 1] == 'x' && a[i][j + 2] == 'x') { ans = 1; } } } } } for (int i = 1; i < 3; i++) { for (int j = 2; j > 0; j--) { if (a[i][j] == '.') { if (a[i - 1][j + 1] == 'x' && a[i + 1][j - 1] == 'x') { ans = 1; } } } } if (ans == 0) { for (int i = 1; i < 3; i++) { for (int j = 1; j < 3; j++) { if (a[i][j] == '.') { if (a[i - 1][j - 1] == 'x' && a[i + 1][j + 1] == 'x') { ans = 1; } } } } } if (ans == 0) { for (int i = 0; i < 4; i++) { for (int j = 1; j <= 2; j++) { if (a[i][j] == '.') { if (a[i][j + 1] == 'x' && a[i][j - 1] == 'x') { ans = 1; } } } } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) { if (a[i][j] == 'x' || a[i][j] == '.') { if (a[i + 1][j] == 'x' && a[i + 2][j] == 'x') { ans = 1; } } } } for (int i = 2; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i][j] == 'x' || a[i][j] == '.') { if (a[i - 1][j] == 'x' && a[i - 2][j] == 'x') { ans = 1; } } } } for (int i = 1; i < 3; i++) { for (int j = 0; j < 4; j++) { if (a[i][j] == 'x' || a[i][j] == '.') { if (a[i - 1][j] == 'x' && a[i + 1][j] == 'x') { ans = 1; } } } } if (ans) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dc[] = {0, 1, 1, 1, 0, -1, -1, -1}; bool in(int r, int c) { return r >= 0 && c >= 0 && r < 4 && c < 4; } char g[10][10]; int main() { for (int i = (0); i < (4); i++) scanf(" %s", g[i]); for (int i = (0); i < (4); i++) for (int j = (0); j < (4); j++) for (int x = (0); x < (8); x++) { int a = i + dr[x], b = j + dc[x]; int c = a + dr[x], d = b + dc[x]; if (in(c, d) && g[i][j] != 'o' && g[a][b] != 'o' && g[c][d] != 'o') { int n = 0; n += (g[i][j] == 'x'); n += (g[a][b] == 'x'); n += (g[c][d] == 'x'); if (n == 2) { puts("YES"); return 0; } } } puts("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int n; int xx[4] = {1, 1, 0, 1}; int yy[4] = {0, 1, 1, -1}; char s[10][10]; bool check() { for (int i = (1), _b = (4); i <= _b; i++) for (int j = (1), _b = (4); j <= _b; j++) { for (int d = (0), _b = (3); d <= _b; d++) { bool ok = true; for (int k = (0), _b = (2); k <= _b; k++) { int x = i + xx[d] * k; int y = j + yy[d] * k; if (x < 1 || x > 4 || y < 1 || y > 4 || s[x][y] != 'x') { ok = false; break; } } if (ok) return true; } } return false; } int main() { for (int i = (1), _b = (4); i <= _b; i++) scanf("%s", s[i] + 1); for (int i = (1), _b = (4); i <= _b; i++) for (int j = (1), _b = (4); j <= _b; j++) if (s[i][j] == '.') { s[i][j] = 'x'; if (check()) { cout << "YES" << endl; return 0; } s[i][j] = '.'; } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; char e[5][5]; int d[12][4] = { {0, 1, 0, -1}, {1, 0, -1, 0}, {1, 1, -1, -1}, {1, -1, -1, 1}, {0, 1, 0, 2}, {0, -1, 0, -2}, {1, 0, 2, 0}, {-1, 0, -2, 0}, {1, 1, 2, 2}, {1, -1, 2, -2}, {-1, -1, -2, -2}, {-1, 1, -2, 2}, }; int check(int x, int y) { int x1, y1, x2, y2; for (int i = 0; i < 12; i++) { x1 = x + d[i][0]; y1 = y + d[i][1]; x2 = x + d[i][2]; y2 = y + d[i][3]; if (x1 >= 0 && x1 <= 3 && y1 >= 0 && y1 <= 3 && x2 >= 0 && x2 <= 3 && y2 >= 0 && y2 <= 3) { if (e[x1][y1] == 'x' && e[x2][y2] == 'x') { return 1; } } } return 0; } int main() { int result = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> e[i][j]; } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (e[i][j] == '.') { result |= check(i, j); } } } if (result == 0) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); char mat[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> mat[i][j]; } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (mat[i][j] == 'x') { if ((i + 2 < 4) && ((mat[i + 1][j] == 'x' && mat[i + 2][j] == '.') || (mat[i + 1][j] == '.' && mat[i + 2][j] == 'x'))) { cout << "YES" << endl; return 0; } if ((i - 2 >= 0) && ((mat[i - 1][j] == 'x' && mat[i - 2][j] == '.') || (mat[i - 1][j] == '.' && mat[i - 2][j] == 'x'))) { cout << "YES" << endl; return 0; } if ((j + 2 < 4) && ((mat[i][j + 1] == 'x' && mat[i][j + 2] == '.') || (mat[i][j + 1] == '.' && mat[i][j + 2] == 'x'))) { cout << "YES" << endl; return 0; } if ((j - 2 >= 0) && ((mat[i][j - 1] == 'x' && mat[i][j - 2] == '.') || (mat[i][j - 1] == '.' && mat[i][j - 2] == 'x'))) { cout << "YES" << endl; return 0; } if ((j + 2 < 4 && i + 2 < 4) && ((mat[i + 1][j + 1] == 'x' && mat[i + 2][j + 2] == '.') || (mat[i + 1][j + 1] == '.' && mat[i + 2][j + 2] == 'x'))) { cout << "YES" << endl; return 0; } if ((j - 2 >= 0 && i + 2 < 4) && ((mat[i + 1][j - 1] == 'x' && mat[i + 2][j - 2] == '.') || (mat[i + 1][j - 1] == '.' && mat[i + 2][j - 2] == 'x'))) { cout << "YES" << endl; return 0; } if ((j - 2 >= 0 && i - 2 >= 0) && ((mat[i - 1][j - 1] == 'x' && mat[i - 2][j - 2] == '.') || (mat[i - 1][j - 1] == '.' && mat[i - 2][j - 2] == 'x'))) { cout << "YES" << endl; return 0; } if ((j + 2 < 4 && i - 2 >= 0) && ((mat[i - 1][j + 1] == 'x' && mat[i - 2][j + 2] == '.') || (mat[i - 1][j + 1] == '.' && mat[i - 2][j + 2] == 'x'))) { cout << "YES" << endl; return 0; } } } } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 1; long long n, m, k, l, r, x, y, z, cnt, ans, sum, T, mx = -1e18, mn = 1e18; char a[5][5]; string s, t; int main() { ios_base::sync_with_stdio(0); for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) cin >> a[i][j]; } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (a[i][j] == '.') { if ((a[i][j + 1] == 'x' && a[i][j - 1] == 'x') || (a[i - 1][j] == 'x' && a[i + 1][j] == 'x') || (a[i - 1][j + 1] == 'x' && a[i + 1][j - 1] == 'x') || (a[i - 1][j - 1] == 'x' && a[i + 1][j + 1] == 'x')) { cout << "YES"; return 0; } } if (a[i][j] == 'x') { if ((a[i][j + 1] == '.' && a[i][j - 1] == 'x') || (a[i - 1][j] == '.' && a[i + 1][j] == 'x') || (a[i - 1][j + 1] == '.' && a[i + 1][j - 1] == 'x') || (a[i - 1][j - 1] == '.' && a[i + 1][j + 1] == 'x')) { cout << "YES"; return 0; } if ((a[i][j + 1] == 'x' && a[i][j - 1] == '.') || (a[i - 1][j] == 'x' && a[i + 1][j] == '.') || (a[i - 1][j + 1] == 'x' && a[i + 1][j - 1] == '.') || (a[i - 1][j - 1] == 'x' && a[i + 1][j + 1] == '.')) { cout << "YES"; return 0; } } } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; template <typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>; template <typename T> using max_pq = priority_queue<T>; const int inf = 2e9 + 5; const long long l_inf = 2e18 + 5; const int mod_v = 1e9 + 7; const int max_n = 1e5 + 5; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, 1, 0, -1}; template <typename T> T gcd(T a, T b) { while (b) { T temp = a % b; a = b; b = temp; } return a; } template <typename T> tuple<T, T, T> egcd(T a, T b) { T x1 = 1, x2 = 0, y1 = 0, y2 = 1; while (b) { T q = a / b, r = a % b; T new_x = x1 - q * x2, new_y = y1 - q * y2; x1 = x2, y1 = y2, x2 = new_x, y2 = new_y; a = b, b = r; } return make_tuple(a, x1, y1); } inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); } template <typename T> inline T mod(T a, T b = mod_v) { return (a % b + b) % b; } template <typename T> inline T mod_inv(T a, T b = mod_v) { return mod(get<1>(egcd(a, b)), b); } template <typename T> inline T sum(T a, T b, T m = mod_v) { return mod(mod(a, m) + mod(b, m), m); } template <typename T> inline T difference(T a, T b, T m = mod_v) { return mod(mod(a, m) - mod(b, m), m); } inline long long product(long long a, long long b, long long m = mod_v) { return mod(mod(a, m) * mod(b, m), m); } inline long long quotient(long long a, long long b, long long m = mod_v) { return mod(mod(a, m) * mod_inv(b, m), m); } template <typename T, typename T2> ostream &operator<<(ostream &s, const pair<T, T2> &p) { return s << p.first << ' ' << p.second << ' '; } template <typename T, typename T2> istream &operator>>(istream &s, pair<T, T2> &p) { return s >> p.first >> p.second; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (auto it : v) s << it << ' '; return s; } template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (auto it = (v).begin(), it_ = (v).end(); it != it_; ++it) s >> *it; return s; } template <typename T> void read_range(T beg, T end) { while (beg != end) cin >> *beg++; } template <typename T> void print_range(T beg, T end) { while (beg != end) cout << *beg++ << ' '; } struct reader { template <typename T> reader &operator,(T &v) { cin >> v; return *this; } } rdr; struct debugger { template <typename T> debugger &operator,(const T &v) { cerr << v << ", "; return *this; } } dbg; bool check(string *ar) { for (int i = 0; i < 4; ++i) for (int j = 0; j < 2; ++j) if (ar[i].substr(j, 3) == "xxx") { return true; } for (int i = 0; i < 4; ++i) for (int j = 0; j < 2; ++j) if (ar[j][i] == 'x' and ar[j + 1][i] == 'x' and ar[j + 2][i] == 'x') return true; if (ar[0][0] == 'x' and ar[1][1] == 'x' and ar[2][2] == 'x') return true; if (ar[1][1] == 'x' and ar[2][2] == 'x' and ar[3][3] == 'x') return true; if (ar[0][1] == 'x' and ar[1][2] == 'x' and ar[2][3] == 'x') return true; if (ar[1][0] == 'x' and ar[2][1] == 'x' and ar[3][2] == 'x') return true; if (ar[0][3] == 'x' and ar[1][2] == 'x' and ar[2][1] == 'x') return true; if (ar[1][2] == 'x' and ar[2][1] == 'x' and ar[3][0] == 'x') return true; if (ar[0][2] == 'x' and ar[1][1] == 'x' and ar[2][0] == 'x') return true; if (ar[1][3] == 'x' and ar[2][2] == 'x' and ar[3][1] == 'x') return true; return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string ar[4]; read_range(ar, ar + 4); bool ok = false; for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) { if (ar[i][j] == '.') { ar[i][j] = 'x'; ok |= check(ar); ar[i][j] = '.'; } } if (ok) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, i, j, k, l, m, x, z, y, t, x1, y1, z1, e, f = 0; long long n1, n2; string s; string a[5]; for (i = 1; i <= 4; i++) { cin >> a[i]; } for (i = 1; i <= 4; i++) { for (j = 2; j < 4; j++) { if (a[i][j] == '.') { if (a[i][j - 1] == 'x' && a[i][j - 2] == 'x') f = 1; } if (a[i][j] == 'x') { if (a[i][j - 1] == '.' && a[i][j - 2] == 'x') f = 1; if (a[i][j - 1] == 'x' && a[i][j - 2] == '.') f = 1; } } } for (i = 3; i <= 4; i++) { for (j = 0; j < 4; j++) { if (a[i][j] == '.') { if (a[i - 1][j] == 'x' && a[i - 2][j] == 'x') f = 1; } if (a[i][j] == 'x') { if (a[i - 1][j] == '.' && a[i - 2][j] == 'x') f = 1; if (a[i - 1][j] == 'x' && a[i - 2][j] == '.') f = 1; } } } for (i = 1; i <= 4; i++) { for (j = 0; j < 4; j++) { if (i - 1 > 0 && j - 1 >= 0 && i - 2 > 0 && j - 2 >= 0) { if (a[i][j] == '.') { if (a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == 'x') f = 1; } if (a[i][j] == 'x') { if (a[i - 1][j - 1] == '.' && a[i - 2][j - 2] == 'x') f = 1; if (a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == '.') f = 1; } } if (i - 1 > 0 && j + 1 < 4 && i - 2 > 0 && j + 2 < 4) { if (a[i][j] == '.') { if (a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == 'x') f = 1; } if (a[i][j] == 'x') { if (a[i - 1][j + 1] == '.' && a[i - 2][j + 2] == 'x') f = 1; if (a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == '.') f = 1; } } } } if (f) cout << "YES" << "\n"; else cout << "NO" << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char M[8][8]; int X1[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int Y1[] = {1, 0, -1, 1, -1, 1, 0, -1}; int X2[] = {1, 1, 1, 0, 0, -1, -1, -1}; int Y2[] = {-1, 0, 1, -1, 1, -1, 0, 1}; bool flag = 0; for (int i = 0; i < 4; i++) scanf("%s", &M[i]); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (M[i][j] == '.') { int u, v, x, y, a, b; for (int k = 0; k < 8; k++) { u = i + X1[k]; v = j + Y1[k]; x = i + X2[k]; y = j + Y2[k]; a = i + 2 * X1[k]; b = j + 2 * Y1[k]; if (u >= 0 && u < 4 && v >= 0 && v < 4 && x >= 0 && x < 4 && y >= 0 && y < 4) { if (M[u][v] == 'x' && M[x][y] == M[u][v]) flag = 1; } if (a >= 0 && a < 4 && b >= 0 && b < 4) { if (M[u][v] == M[a][b] && M[u][v] == 'x') flag = 1; } } } } } if (flag) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int arr[8] = {0, 1, 1, 1, 0, -1, -1, -1}; int brr[8] = {1, 1, 0, -1, -1, -1, 0, 1}; string str[100]; int bfs(int i, int j, int k, int c, int tt) { if (c == 2) { return 1; } if (i < 0 || j < 0 || i >= 4 || j >= 4) { return 0; } if (str[i][j] == 'x') { return bfs(i + arr[k - 1], j + brr[k - 1], k, c + 1, tt); } else if (str[i][j] == '.' && tt == 1) { return bfs(i + arr[k - 1], j + brr[k - 1], k, c + 1, tt - 1); } return 0; } int main() { for (int i = 0; i < 4; i++) { cin >> str[i]; } int flag = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (str[i][j] == 'x') { for (int k = 1; k <= 8; k++) { int xxx = bfs(i + arr[k - 1], j + brr[k - 1], k, 0, 1); if (xxx == 1) { flag = 1; cout << "YES" << endl; return 0; } } } } } if (flag == 0) { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; bool check(char A[][4], long long int i, long long int j) { if (i == 0) { if (j == 0) { if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } if (A[i + 1][j + 1] == 'X' && A[i + 2][j + 2] == '.') { return true; } if (A[i + 1][j + 1] == '.' && A[i + 2][j + 2] == 'X') { return true; } if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } return false; } if (j == 3) { if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } if (A[i + 1][j - 1] == 'X' && A[i + 2][j - 2] == '.') { return true; } if (A[i + 1][j - 1] == '.' && A[i + 2][j - 2] == 'X') { return true; } if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } return false; } if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } if (j - 2 >= 0) { if (A[i + 1][j - 1] == 'X' && A[i + 2][j - 2] == '.') { return true; } if (A[i + 1][j - 1] == '.' && A[i + 2][j - 2] == 'X') { return true; } if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } } else { if (A[i + 1][j + 1] == 'X' && A[i + 2][j + 2] == '.') { return true; } if (A[i + 1][j + 1] == '.' && A[i + 2][j + 2] == 'X') { return true; } if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } } if (A[i][j - 1] == 'X' && A[i][j + 1] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j + 1] == 'X') { return true; } return false; } if (i == 3) { if (j == 0) { if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } if (A[i - 1][j + 1] == 'X' && A[i - 2][j + 2] == '.') { return true; } if (A[i - 1][j + 1] == '.' && A[i - 2][j + 2] == 'X') { return true; } if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } return false; } if (j == 3) { if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } if (A[i - 1][j - 1] == 'X' && A[i - 2][j - 2] == '.') { return true; } if (A[i - 1][j - 1] == '.' && A[i - 2][j - 2] == 'X') { return true; } if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } return false; } if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } if (j - 2 >= 0) { if (A[i - 1][j - 1] == 'X' && A[i - 2][j - 2] == '.') { return true; } if (A[i - 1][j - 1] == '.' && A[i - 2][j - 2] == 'X') { return true; } if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } } else { if (A[i - 1][j + 1] == 'X' && A[i - 2][j + 2] == '.') { return true; } if (A[i - 1][j + 1] == '.' && A[i - 2][j + 2] == 'X') { return true; } if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } } if (A[i][j - 1] == 'X' && A[i][j + 1] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j + 1] == 'X') { return true; } return false; } else { if (j == 0) { if (i - 2 >= 0) { if (A[i - 1][j + 1] == 'X' && A[i - 2][j + 2] == '.') { return true; } if (A[i - 1][j + 1] == '.' && A[i - 2][j + 2] == 'X') { return true; } if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } } else { if (A[i + 1][j + 1] == 'X' && A[i + 2][j + 2] == '.') { return true; } if (A[i + 1][j + 1] == '.' && A[i + 2][j + 2] == 'X') { return true; } if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } } if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } if (A[i - 1][j] == 'X' && A[i + 1][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i + 1][j] == 'X') { return true; } return false; } if (j == 3) { if (i - 2 >= 0) { if (A[i - 1][j - 1] == 'X' && A[i - 2][j - 2] == '.') { return true; } if (A[i - 1][j - 1] == '.' && A[i - 2][j - 2] == 'X') { return true; } if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } } else { if (A[i + 1][j - 1] == 'X' && A[i + 2][j - 2] == '.') { return true; } if (A[i + 1][j - 1] == '.' && A[i + 2][j - 2] == 'X') { return true; } if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } } if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } if (A[i - 1][j] == 'X' && A[i + 1][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i + 1][j] == 'X') { return true; } return false; } else { if (i - 2 >= 0) { if (j - 2 >= 0) { if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } if (A[i - 1][j - 1] == 'X' && A[i - 2][j - 2] == '.') { return true; } if (A[i - 1][j - 1] == '.' && A[i - 2][j - 2] == 'X') { return true; } if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } } else { if (A[i - 1][j] == 'X' && A[i - 2][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i - 2][j] == 'X') { return true; } if (A[i - 1][j + 1] == 'X' && A[i - 2][j + 2] == '.') { return true; } if (A[i - 1][j + 1] == '.' && A[i - 2][j + 2] == 'X') { return true; } if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } } } else { if (j - 2 >= 0) { if (A[i][j - 1] == 'X' && A[i][j - 2] == '.') { return true; } if (A[i][j - 1] == '.' && A[i][j - 2] == 'X') { return true; } if (A[i + 1][j - 1] == 'X' && A[i + 2][j - 2] == '.') { return true; } if (A[i + 1][j - 1] == '.' && A[i + 2][j - 2] == 'X') { return true; } if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } } else { if (A[i][j + 1] == 'X' && A[i][j + 2] == '.') { return true; } if (A[i][j + 1] == '.' && A[i][j + 2] == 'X') { return true; } if (A[i + 1][j + 1] == 'X' && A[i + 2][j + 2] == '.') { return true; } if (A[i + 1][j + 1] == '.' && A[i + 2][j + 2] == 'X') { return true; } if (A[i + 1][j] == 'X' && A[i + 2][j] == '.') { return true; } if (A[i + 1][j] == '.' && A[i + 2][j] == 'X') { return true; } } } if (A[i - 1][j] == 'X' && A[i + 1][j] == '.') { return true; } if (A[i - 1][j] == '.' && A[i + 1][j] == 'X') { return true; } if (A[i][j - 1] == 'X' && A[i][j + 1] == '.') { return true; } if (A[i][j - 1] == 'X' && A[i][j + 1] == '.') { return true; } return false; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector<pair<long long int, long long int> > v; char A[4][4]; for (long long int i = 0; i < 4; i++) { for (long long int j = 0; j < 4; j++) { cin >> A[i][j]; if (A[i][j] == 'x') { A[i][j] = 'X'; v.push_back(make_pair(i, j)); } } } string s = "NO"; for (auto i : v) { if (check(A, i.first, i.second)) { s = "YES"; break; } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { char a[10][10]; int n = 5; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { cin >> a[i][j]; } } bool v = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if ((a[i][j] == 'x' && a[i][j + 1] == 'x' && (a[i][j - 1] == '.' || a[i][j + 2] == '.')) || (a[i][j] == 'x' && a[i][j + 2] == 'x' && a[i][j + 1] == '.')) v = 1; } } for (int j = 1; j < n; j++) { for (int i = 1; i < n; i++) { if ((a[i][j] == 'x' && a[i + 1][j] == 'x' && (a[i - 1][j] == '.' || a[i + 2][j] == '.')) || (a[i][j] == 'x' && a[i + 2][j] == 'x' && a[i + 1][j] == '.')) v = 1; } } if (a[3][1] == '.' && a[2][2] == 'x' && a[1][3] == 'x') v = 1; if (a[3][1] == 'x' && a[2][2] == '.' && a[1][3] == 'x') v = 1; if (a[3][1] == 'x' && a[2][2] == 'x' && a[1][3] == '.') v = 1; if (a[4][1] == '.' && a[3][2] == 'x' && a[2][3] == 'x') v = 1; if (a[4][1] == 'x' && a[3][2] == '.' && a[2][3] == 'x') v = 1; if (a[4][1] == 'x' && a[3][2] == 'x' && a[2][3] == '.') v = 1; if (a[3][2] == '.' && a[2][3] == 'x' && a[1][4] == 'x') v = 1; if (a[3][2] == 'x' && a[2][3] == '.' && a[1][4] == 'x') v = 1; if (a[3][2] == 'x' && a[2][3] == 'x' && a[1][4] == '.') v = 1; if (a[4][2] == '.' && a[3][3] == 'x' && a[2][4] == 'x') v = 1; if (a[4][2] == 'x' && a[3][3] == '.' && a[2][4] == 'x') v = 1; if (a[4][2] == 'x' && a[3][3] == 'x' && a[2][4] == '.') v = 1; if (a[1][2] == '.' && a[2][3] == 'x' && a[3][4] == 'x') v = 1; if (a[1][2] == 'x' && a[2][3] == '.' && a[3][4] == 'x') v = 1; if (a[1][2] == 'x' && a[2][3] == 'x' && a[3][4] == '.') v = 1; if (a[1][1] == '.' && a[2][2] == 'x' && a[3][3] == 'x') v = 1; if (a[1][1] == 'x' && a[2][2] == '.' && a[3][3] == 'x') v = 1; if (a[1][1] == 'x' && a[2][2] == 'x' && a[3][3] == '.') v = 1; if (a[2][2] == '.' && a[3][3] == 'x' && a[4][4] == 'x') v = 1; if (a[2][2] == 'x' && a[3][3] == '.' && a[4][4] == 'x') v = 1; if (a[2][2] == 'x' && a[3][3] == 'x' && a[4][4] == '.') v = 1; if (a[2][1] == '.' && a[3][2] == 'x' && a[4][3] == 'x') v = 1; if (a[2][1] == 'x' && a[3][2] == '.' && a[4][3] == 'x') v = 1; if (a[2][1] == 'x' && a[3][2] == 'x' && a[4][3] == '.') v = 1; if (v) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> int main(void) { char board[4][6]; int i, j, k; const int ans = 2 * (int)'x' + '.'; for (i = 0; i < 4; i++) scanf("%s%*c", board[i]); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i <= 1 && board[i][j] + board[i + 1][j] + board[i + 2][j] == ans) { puts("YES"); return 0; } if (j <= 1 && board[i][j] + board[i][j + 1] + board[i][j + 2] == ans) { puts("YES"); return 0; } if (i <= 1 && j <= 1 && board[i][j] + board[i + 1][j + 1] + board[i + 2][j + 2] == ans) { puts("YES"); return 0; } if (i >= 2 && j <= 1 && board[i][j] + board[i - 1][j + 1] + board[i - 2][j + 2] == ans) { puts("YES"); return 0; } } } puts("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; bool ok(int i, int j) { return i >= 0 && j >= 0 && i < 4 && j < 4; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); vector<int> d1{-1, 0, 1}; string s[4]; for (int i = 0; i < 4; ++i) cin >> s[i]; bool can = false, isnt = false; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (s[i][j] == '.') { s[i][j] = 'x'; for (int ii = 0; ii < 4; ++ii) { for (int jj = 0; jj < 4; ++jj) { if (s[ii][jj] == 'x') { for (auto del1 : d1) for (auto del2 : d1) for (auto del3 : d1) for (auto del4 : d1) { if (del1 + del3 || del2 + del4) continue; if (!del1 && !del2 && !del3 && !del4) continue; if (ok(ii + del1, jj + del2) && ok(ii + del3, jj + del4)) { if (s[ii + del1][jj + del2] == s[ii + del3][jj + del4] && s[ii + del1][jj + del2] == 'x') { can = true; } } } } } } s[i][j] = '.'; } if (s[i][j] == 'o') { for (int ii = 0; ii < 4; ++ii) { for (int jj = 0; jj < 4; ++jj) { if (s[ii][jj] == 'o') { for (auto del1 : d1) for (auto del2 : d1) for (auto del3 : d1) for (auto del4 : d1) { if (del1 + del3 || del2 + del4) continue; if (!del1 && !del2 && !del3 && !del4) continue; if (ok(ii + del1, jj + del2) && ok(ii + del3, jj + del4)) { if (s[ii + del1][jj + del2] == s[ii + del3][jj + del4] && s[ii + del1][jj + del2] == 'o') { isnt = true; } } } } } } } } } cout << (isnt ? "NO\n" : (can ? "YES\n" : "NO\n")); }
#include <bits/stdc++.h> using namespace std; int main() { int n = 4; vector<string> v; for (int i = 0; i < n; i++) { string s; cin >> s; v.push_back(s); } for (int i = 0; i < v.size(); i++) { for (int j = 0; j < v[i].size(); j++) { if (v[i][j] == 'x') { if (i < n - 1) { if (v[i + 1][j] == 'x' && i + 2 < n) { if (v[i + 2][j] == '.' && i + 2 < n) { cout << "YES"; return 0; } } if (v[i + 1][j] == '.' && i + 2 < n) { if (v[i + 2][j] == 'x' && i + 2 < n) { cout << "YES"; return 0; } } } if (i > 0) { if (v[i - 1][j] == 'x' && i - 2 >= 0) { if (v[i - 2][j] == '.') { cout << "YES"; return 0; } } if (v[i - 1][j] == '.' && i - 2 >= 0) { if (v[i - 2][j] == 'x') { cout << "YES"; return 0; } } } if (j < n - 1) { if (v[i][j + 1] == 'x' && j + 2 < n) { if (v[i][j + 2] == '.') { cout << "YES"; return 0; } } if (v[i][j + 1] == '.' && j + 2 < n) { if (v[i][j + 2] == 'x') { cout << "YES"; return 0; } } } if (j > 0) { if (v[i][j - 1] == 'x' && j - 2 >= 0) { if (v[i][j - 2] == '.') { cout << "YES"; return 0; } } if (v[i][j - 1] == '.' && j - 2 >= 0) { if (v[i][j - 2] == 'x') { cout << "YES"; return 0; } } } if (i < n - 1 && j < n - 1) { if (v[i + 1][j + 1] == 'x' && i + 2 < n && j + 2 < n) { if (v[i + 2][j + 2] == '.') { cout << "YES"; return 0; } } if (v[i + 1][j + 1] == '.' && i + 2 < n && j + 2 < n) { if (v[i + 2][j + 2] == 'x') { cout << "YES"; return 0; } } } if (i < n - 1 && j > 0) { if (v[i + 1][j - 1] == 'x' && i + 2 < n && j - 2 >= 0) { if (v[i + 2][j - 2] == '.') { cout << "YES"; return 0; } } if (v[i + 1][j - 1] == '.' && i + 2 < n && j - 2 >= 0) { if (v[i + 2][j - 2] == 'x') { cout << "YES"; return 0; } } } if (i > 0 && j < n - 1) { if (v[i - 1][j + 1] == 'x' && i - 2 >= 0 && j + 2 < n) { if (v[i - 2][j + 2] == '.') { cout << "YES"; return 0; } } if (v[i - 1][j + 1] == '.' && i - 2 >= 0 && j + 2 < n) { if (v[i - 2][j + 2] == 'x') { cout << "YES"; return 0; } } } if (i > 0 && j > 0) { if (v[i - 1][j - 1] == 'x' && i - 2 >= 0 && j - 2 >= 0) { if (v[i - 2][j - 2] == '.') { cout << "YES"; return 0; } } if (v[i - 1][j - 1] == '.' && i - 2 >= 0 && j - 2 >= 0) { if (v[i - 2][j - 2] == 'x') { cout << "YES"; return 0; } } } } } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int a[5][5]; int judge() { int tmp; for (int i = 0; i < 4; ++i) { if ((tmp = a[i][0] + a[i][1] + a[i][2]) == 3) return 1; else if (tmp == -3) return 0; if ((tmp = a[i][3] + a[i][1] + a[i][2]) == 3) return 1; else if (tmp == -3) return 0; if ((tmp = a[0][i] + a[1][i] + a[2][i]) == 3) return 1; else if (tmp == -3) return 0; if ((tmp = a[3][i] + a[1][i] + a[2][i]) == 3) return 1; else if (tmp == -3) return 0; } for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) { tmp = 0; for (int k = 0; k < 3; ++k) tmp += a[i + k][j + k]; if (tmp == 3) return 1; else if (tmp == -3) return 0; } for (int i = 0; i < 2; ++i) for (int j = 2; j < 4; ++j) { tmp = 0; for (int k = 0; k < 3; ++k) tmp += a[i + k][j - k]; if (tmp == 3) return 1; else if (tmp == -3) return 0; } return -1; } int bfs(int pl) { int tmp, flag = 0; if ((tmp = judge()) >= 0) return tmp; for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) if (a[i][j] == 0) { a[i][j] = pl; if (bfs(-pl) == 0) flag = 1; a[i][j] = 0; if (flag) return 0; } return 1; } int main() { char s[5], num = 0; for (int i = 0; i < 4; ++i) { scanf("%s", s); for (int j = 0; j < 4; ++j) { if (s[j] == 'x') { num++; a[i][j] = 1; } else if (s[j] == 'o') { num++; a[i][j] = -1; } else a[i][j] = 0; } } for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) if (a[i][j] == 0) { a[i][j] = 1; if (judge() == 1) { printf("YES\n"); return 0; } a[i][j] = 0; } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; ifstream fin("f.in"); int n; char g[5][5]; bool _check(char g[5][5], int i, int j, int dir, int cnt) { if (cnt == 3) return true; if (i < 0 || j >= 4) return false; switch (dir) { case 1: return g[i][j] == 'x' && _check(g, i - 1, j, dir, cnt + 1); case 2: return g[i][j] == 'x' && _check(g, i + 1, j, dir, cnt + 1); case 3: return g[i][j] == 'x' && _check(g, i, j - 1, dir, cnt + 1); case 4: return g[i][j] == 'x' && _check(g, i, j + 1, dir, cnt + 1); case 5: return g[i][j] == 'x' && _check(g, i - 1, j - 1, dir, cnt + 1); case 6: return g[i][j] == 'x' && _check(g, i - 1, j + 1, dir, cnt + 1); case 7: return g[i][j] == 'x' && _check(g, i + 1, j - 1, dir, cnt + 1); case 8: return g[i][j] == 'x' && _check(g, i + 1, j + 1, dir, cnt + 1); } } bool check(char g[5][5]) { for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (g[i][j] == 'x') { if (_check(g, i - 1, j, 1, 1) || _check(g, i + 1, j, 2, 1) || _check(g, i, j - 1, 3, 1) || _check(g, i, j + 1, 4, 1) || _check(g, i - 1, j - 1, 5, 1) || _check(g, i - 1, j + 1, 6, 1) || _check(g, i + 1, j - 1, 7, 1) || _check(g, i + 1, j + 1, 8, 1)) return true; } } } return false; } void solve() { for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { cin >> g[i][j]; } } for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (g[i][j] == '.') { g[i][j] = 'x'; if (check(g)) { cout << "YES" << endl; return; } g[i][j] = '.'; } } } cout << "NO" << endl; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int inf = INT_MAX; template <typename type> inline type sqr(type value) { return (value * value); } char n, a[101][101]; vector<pair<int, int> > ans; bool first; int main() { for (int i = 2; i <= 5; i++) { for (int j = 2; j <= 5; j++) { cin >> a[i][j]; } } for (int i = 2; i <= 5; i++) { for (int j = 2; j <= 5; j++) { if (a[i][j] == '.') { if (a[i - 1][j] == 'x' && a[i - 2][j] == 'x') { cout << "YES"; return 0; } if (a[i][j - 1] == 'x' && a[i][j - 2] == 'x') { cout << "YES"; return 0; } if (a[i + 1][j] == 'x' && a[i + 2][j] == 'x') { cout << "YES"; return 0; } if (a[i][j + 1] == 'x' && a[i][j + 2] == 'x') { cout << "YES"; return 0; } if (a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == 'x') { cout << "YES"; return 0; } if (a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == 'x') { cout << "YES"; return 0; } if (a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == 'x') { cout << "YES"; return 0; } if (a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == 'x') { cout << "YES"; return 0; } if (a[i + 1][j] == 'x' && a[i - 1][j] == 'x') { cout << "YES"; return 0; } if (a[i][j + 1] == 'x' && a[i][j - 1] == 'x') { cout << "YES"; return 0; } if (a[i - 1][j - 1] == 'x' && a[i + 1][j + 1] == 'x') { cout << "YES"; return 0; } if (a[i + 1][j - 1] == 'x' && a[i - 1][j + 1] == 'x') { cout << "YES"; return 0; } } } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; char a[4][4]; int main() { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) cin >> a[i][j]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { if (a[i][j] == 'x') { if (i <= 1) if (a[i + 1][j] == 'x' && a[i + 2][j] == '.' || a[i + 1][j] == '.' && a[i + 2][j] == 'x') { cout << "YES"; return 0; } if (i >= 2) if (a[i - 1][j] == 'x' && a[i - 2][j] == '.' || a[i - 1][j] == '.' && a[i - 2][j] == 'x') { cout << "YES"; return 0; } if (j <= 1) if (a[i][j + 1] == 'x' && a[i][j + 2] == '.' || a[i][j + 1] == '.' && a[i][j + 2] == 'x') { cout << "YES"; return 0; } if (j >= 2) if (a[i][j - 1] == 'x' && a[i][j - 2] == '.' || a[i][j - 1] == '.' && a[i][j - 2] == 'x') { cout << "YES"; return 0; } if (j >= 2 && i <= 1) { if (a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == '.' || a[i + 1][j - 1] == '.' && a[i + 2][j - 2] == 'x') { cout << "YES"; return 0; } } if (j >= 2 && i >= 2) { if (a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == '.' || a[i - 1][j - 1] == '.' && a[i - 2][j - 2] == 'x') { cout << "YES"; return 0; } } if (j <= 1 && i >= 2) { if (a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == '.' || a[i - 1][j + 1] == '.' && a[i - 2][j + 2] == 'x') { cout << "YES"; return 0; } } if (j <= 1 && i <= 1) { if (a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == '.' || a[i + 1][j + 1] == '.' && a[i + 2][j + 2] == 'x') { cout << "YES"; return 0; } } } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, aaa = 0; char a[4][4]; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { cin >> a[i][j]; } } for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { char b[3][3]; long long int aa = 0; b[0][0] = a[i][j]; b[0][1] = a[i][j + 1]; b[0][2] = a[i][j + 2]; b[1][0] = a[i + 1][j]; b[1][1] = a[i + 1][j + 1]; b[1][2] = a[i + 1][j + 2]; b[2][0] = a[i + 2][j]; b[2][1] = a[i + 2][j + 1]; b[2][2] = a[i + 2][j + 2]; if ((b[0][0] == 'x' && b[0][1] == 'x' && b[0][2] == 'x') || (b[1][0] == 'x' && b[1][1] == 'x' && b[1][2] == 'x') || (b[2][0] == 'x' && b[2][1] == 'x' && b[2][2] == 'x') || (b[0][0] == 'x' && b[1][0] == 'x' && b[2][0] == 'x') || (b[0][1] == 'x' && b[1][1] == 'x' && b[2][1] == 'x') || (b[0][2] == 'x' && b[1][2] == 'x' && b[2][2] == 'x') || (b[0][0] == 'x' && b[1][1] == 'x' && b[2][2] == 'x') || (b[0][2] == 'x' && b[1][1] == 'x' && b[2][0] == 'x')) { aaa = 1; cout << "YES" << endl; return 0; } else if ((b[0][0] == '.' && b[0][1] == 'x' && b[0][2] == 'x') || (b[1][0] == '.' && b[1][1] == 'x' && b[1][2] == 'x') || (b[2][0] == '.' && b[2][1] == 'x' && b[2][2] == 'x') || (b[0][0] == '.' && b[1][0] == 'x' && b[2][0] == 'x') || (b[0][1] == '.' && b[1][1] == 'x' && b[2][1] == 'x') || (b[0][2] == '.' && b[1][2] == 'x' && b[2][2] == 'x') || (b[0][0] == '.' && b[1][1] == 'x' && b[2][2] == 'x') || (b[0][2] == '.' && b[1][1] == 'x' && b[2][0] == 'x')) { aaa = 1; cout << "YES" << endl; return 0; } else if ((b[0][0] == 'x' && b[0][1] == '.' && b[0][2] == 'x') || (b[1][0] == 'x' && b[1][1] == '.' && b[1][2] == 'x') || (b[2][0] == 'x' && b[2][1] == '.' && b[2][2] == 'x') || (b[0][0] == 'x' && b[1][0] == '.' && b[2][0] == 'x') || (b[0][1] == 'x' && b[1][1] == '.' && b[2][1] == 'x') || (b[0][2] == 'x' && b[1][2] == '.' && b[2][2] == 'x') || (b[0][0] == 'x' && b[1][1] == '.' && b[2][2] == 'x') || (b[0][2] == 'x' && b[1][1] == '.' && b[2][0] == 'x')) { aaa = 1; cout << "YES" << endl; return 0; } else if ((b[0][0] == 'x' && b[0][1] == 'x' && b[0][2] == '.') || (b[1][0] == 'x' && b[1][1] == 'x' && b[1][2] == '.') || (b[2][0] == 'x' && b[2][1] == 'x' && b[2][2] == '.') || (b[0][0] == 'x' && b[1][0] == 'x' && b[2][0] == '.') || (b[0][1] == 'x' && b[1][1] == 'x' && b[2][1] == '.') || (b[0][2] == 'x' && b[1][2] == 'x' && b[2][2] == '.') || (b[0][0] == 'x' && b[1][1] == 'x' && b[2][2] == '.') || (b[0][2] == 'x' && b[1][1] == 'x' && b[2][0] == '.')) { aaa = 1; cout << "YES" << endl; return 0; } } } if (aaa == 0) cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; void adskiy_razgon() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int mxN = 1e+9 + 7; const long long INF = 1e+18 + 7; long long nod(long long a, long long b) { if (b > a) { swap(a, b); } while (b > 0) { a %= b; swap(a, b); } return a; } long long nok(long long a, long long b) { return a * b / nod(a, b); } void sp(long long a, double b) { cout << fixed << setprecision(a) << b; } long long binpow(long long a, long long n) { if (n == 0) { return 1; } if (n % 2 == 1) { return binpow(a, n - 1) * a; } else { long long b = binpow(a, n / 2); return b * b; } } string s[100]; void solve() { for (int i = 0; i < 4; ++i) { cin >> s[i]; } string prov = "..x"; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { string word = s[i].substr((j), (3)); sort(word.begin(), word.end()); if (word == ".xx" || word == "xxx") { cout << "YES"; return; } } } for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { string word = ""; word += s[i][j]; word += s[i + 1][j]; word += s[i + 2][j]; sort(word.begin(), word.end()); if (word == ".xx" || word == "xxx") { cout << "YES"; return; } string word2 = ""; word2 += s[i][j]; word2 += s[i + 1][j + 1]; word2 += s[i + 2][j + 2]; sort(word2.begin(), word2.end()); if (word2 == ".xx" || word2 == "xxx") { cout << "YES"; return; } string word3 = ""; if (i >= 2) { word3 += s[i][j]; word3 += s[i - 1][j + 1]; word3 += s[i - 2][j + 2]; } sort(word3.begin(), word3.end()); if (word3 == ".xx" || word3 == "xxx") { cout << "YES"; return; } } } cout << "NO"; } int main() { adskiy_razgon(); long long t = 1; for (int i = 1; i <= t; ++i) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; char board[10][10]; int main() { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) cin >> board[i][j]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (board[i][j] == 'x' && board[i + 1][j] == 'x' && board[i + 2][j] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i - 1][j] == 'x' && board[i - 2][j] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i][j + 1] == 'x' && board[i][j + 2] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i][j - 1] == 'x' && board[i][j - 2] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i + 2][j] == 'x' && board[i + 1][j] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i - 2][j] == 'x' && board[i - 1][j] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i][j + 2] == 'x' && board[i][j + 1] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i][j - 2] == 'x' && board[i][j - 1] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i - 1][j - 1] == 'x' && board[i - 2][j - 2] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i + 1][j + 1] == 'x' && board[i + 2][j + 2] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i - 1][j + 1] == 'x' && board[i + 1][j - 1] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i + 1][j - 1] == 'x' && board[i - 1][j + 1] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i + 2][j + 2] == 'x' && board[i + 1][j + 1] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i - 2][j - 2] == 'x' && board[i - 1][j - 1] == '.') { cout << "YES"; return 0; } if (board[i][j] == 'x' && board[i - 2][j + 2] == 'x' && board[i - 1][j + 1] == '.') { cout << "YES"; return 0; } } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char a[5][5]; for (int i = 0; i < 4; i++) { scanf("%s", a[i]); } int ff = 0; for (int i = 0; i < 4; i++) { for (int h = 0; h <= 1; h++) { int h1 = 0, h2 = 0; for (int j = h; j < 3 + h; j++) { if (a[i][j] == 'x') h1++; else if (a[i][j] == '.') h2++; } if (h2 <= 1 && h1 + h2 == 3) ff = 1; } } for (int i = 0; i < 4; i++) { for (int h = 0; h <= 1; h++) { int h1 = 0, h2 = 0; for (int j = h; j < 3 + h; j++) { if (a[j][i] == 'x') h1++; else if (a[j][i] == '.') h2++; } if (h2 <= 1 && h1 + h2 == 3) ff = 1; } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { int h1 = 0, h2 = 0; for (int h = 0; h < 3 && i + h < 4 && j + h < 4; h++) { if (a[i + h][j + h] == 'x') { h1++; } else if (a[i + h][j + h] == '.') { h2++; } } if (h2 <= 1 && h1 + h2 == 3) ff = 1; } } for (int i = 0; i < 4; i++) { for (int j = 4; j >= 0; j--) { int h1 = 0, h2 = 0; for (int h = 0; h < 3 && i + h < 4 && j - h >= 0; h++) { if (a[i + h][j - h] == 'x') { h1++; } else if (a[i + h][j - h] == '.') { h2++; } } if (h2 <= 1 && h1 + h2 == 3) ff = 1; } } if (ff) puts("YES"); else puts("NO"); }
#include <bits/stdc++.h> using namespace std; char c[5][5]; int main() { for (int i = 0; i < 4; i++) scanf("%s", c[i]); bool rj = false; int x = 0, t = 0; for (int i = 0; i < 2; i++) for (int j = 0; j < 4; j++) { x = (c[i][j] == 'x') + (c[i + 1][j] == 'x') + (c[i + 2][j] == 'x'); t = (c[i][j] == '.') + (c[i + 1][j] == '.') + (c[i + 2][j] == '.'); if (x == 2 && t == 1) rj = true; } for (int i = 0; i < 4; i++) for (int j = 0; j < 2; j++) { x = (c[i][j] == 'x') + (c[i][j + 1] == 'x') + (c[i][j + 2] == 'x'); t = (c[i][j] == '.') + (c[i][j + 1] == '.') + (c[i][j + 2] == '.'); if (x == 2 && t == 1) rj = true; } for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) { x = (c[i][j] == 'x') + (c[i + 1][j + 1] == 'x') + (c[i + 2][j + 2] == 'x'); t = (c[i][j] == '.') + (c[i + 1][j + 1] == '.') + (c[i + 2][j + 2] == '.'); if (x == 2 && t == 1) rj = true; } for (int i = 2; i < 4; i++) for (int j = 0; j < 2; j++) { x = (c[i][j] == 'x') + (c[i - 1][j + 1] == 'x') + (c[i - 2][j + 2] == 'x'); t = (c[i][j] == '.') + (c[i - 1][j + 1] == '.') + (c[i - 2][j + 2] == '.'); if (x == 2 && t == 1) rj = true; } printf(rj ? "YES\n" : "NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? "YES" : "NO"); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { x += y; if (x >= mod) x -= mod; assert(x >= 0 && x < mod); } void et() { puts("-1"); exit(0); } char s[8][8]; bool ck() { for (int(i) = 1; (i) <= (int)(4); (i)++) for (int(j) = 1; (j) <= (int)(4); (j)++) if (s[i][j] == 'x') { if (s[i - 1][j - 1] == 'x' && s[i + 1][j + 1] == 'x') return 1; if (s[i - 1][j] == 'x' && s[i + 1][j] == 'x') return 1; if (s[i][j - 1] == 'x' && s[i][j + 1] == 'x') return 1; if (s[i - 1][j + 1] == 'x' && s[i + 1][j - 1] == 'x') return 1; } return 0; } void fmain(int tid) { for (int(i) = 1; (i) <= (int)(4); (i)++) scanf("%s", s[i] + 1); for (int(i) = 1; (i) <= (int)(4); (i)++) for (int(j) = 1; (j) <= (int)(4); (j)++) if (s[i][j] == '.') { s[i][j] = 'x'; if (ck()) etp(1); s[i][j] = '.'; } etp(); } int main() { int t = 1; for (int(i) = 1; (i) <= (int)(t); (i)++) { fmain(i); } return 0; }
#include <bits/stdc++.h> const int go[4][2] = {0, 1, 1, 0, 1, 1, 1, -1}; char s[55][55]; bool chk() { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { bool ok[4]; for (int tp = 0; tp < 4; tp++) ok[tp] = true; for (int k = 0; k < 3; k++) for (int tp = 0; tp < 4; tp++) { int x = i + go[tp][0] * k, y = j + go[tp][1] * k; if (x < 0 || x > 3 || y < 0 || y > 3 || s[x][y] != 'x') ok[tp] = false; } for (int tp = 0; tp < 4; tp++) if (ok[tp]) return true; } return false; } int main() { for (int i = 0; i < 4; i++) scanf("%s", s[i]); for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) if (s[i][j] == '.') { s[i][j] = 'x'; if (chk()) { printf("YES\n"); return 0; } s[i][j] = '.'; } printf("NO\n"); return 0; }
#include <bits/stdc++.h> char s1[6][6]; int judge; int s2[8][4] = {0, 1, 0, 2, -1, 1, -2, 2, -1, 0, -2, 0, -1, -1, -2, -2, 0, -1, 0, -2, 1, -1, 2, -2, 1, 0, 2, 0, 1, 1, 2, 2}; int judge1(int x, int y) { if (x <= 4 && x >= 1 && y <= 4 && y >= 1) return 1; else return 0; } int dfs(int x, int y) { int a, b, sum, all; for (a = 0; a < 8; a++) { sum = 0; all = 0; if (s1[s2[a][0] + x][s2[a][1] + y] == 'x' && judge1(s2[a][0] + x, s2[a][1] + y)) sum++; if (s1[s2[a][0] + x][s2[a][1] + y] == '.' && judge1(s2[a][0] + x, s2[a][1] + y)) all++; if (s1[s2[a][2] + x][s2[a][3] + y] == 'x' && judge1(s2[a][2] + x, s2[a][3] + y)) sum++; if (s1[s2[a][2] + x][s2[a][3] + y] == '.' && judge1(s2[a][2] + x, s2[a][3] + y)) all++; if (sum == 1 && all == 1) return 1; } return 0; } int main() { int a, b; for (a = 1; a <= 4; a++) gets(s1[a] + 1); for (a = 1; a <= 4; a++) { for (b = 1; b <= 4; b++) { if (s1[a][b] == 'x') judge = dfs(a, b); if (judge) break; } if (judge) break; } if (judge) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> int main() { char a[6][7] = {0}; int i, j; for (i = 1; i < 5; i++) { for (j = 1; j < 6; j++) { scanf("%c", &a[i][j]); } } for (i = 1; i < 5; i++) { for (j = 1; j < 5; j++) { if (a[i][j] == 'x') { if (a[i][j + 1] == 'x' && a[i][j - 1] == '.') { printf("YES\n"); return 0; } if (a[i][j + 1] == '.' && a[i][j - 1] == 'x') { printf("YES\n"); return 0; } if (a[i + 1][j] == 'x' && a[i - 1][j] == '.') { printf("YES\n"); return 0; } if (a[i + 1][j] == '.' && a[i - 1][j] == 'x') { printf("YES\n"); return 0; } if (a[i + 1][j + 1] == '.' && a[i - 1][j - 1] == 'x') { printf("YES\n"); return 0; } if (a[i + 1][j + 1] == 'x' && a[i - 1][j - 1] == '.') { printf("YES\n"); return 0; } if (a[i - 1][j + 1] == '.' && a[i + 1][j - 1] == 'x') { printf("YES\n"); return 0; } if (a[i - 1][j + 1] == 'x' && a[i + 1][j - 1] == '.') { printf("YES\n"); return 0; } } if (a[i][j] == '.') { if (((a[i + 1][j] == 'x') && (a[i - 1][j] == 'x')) || ((a[i][j + 1] == 'x') && (a[i][j - 1] == 'x')) || ((a[i + 1][j + 1] == 'x') && (a[i - 1][j - 1] == 'x')) || ((a[i - 1][j + 1] == 'x') && (a[i + 1][j - 1] == 'x'))) { printf("YES\n"); return 0; } } } } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 0) return power(a * a % 1000000007, b / 2); return a * power(a, b - 1) % 1000000007; } long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } int main(int argc, char** argv) { vector<string> a(4); cin >> a[0] >> a[1] >> a[2] >> a[3]; vector<string> pos; for (int i = 0; i < 4; i++) { for (int j = 0; j < 2; j++) { pos.push_back(a[i].substr(j, 3)); string g = ""; for (int t = 0; t < 3; t++) g += a[j + t][i]; pos.push_back(g); } } string x = ""; pos.push_back(x + a[0][0] + a[1][1] + a[2][2]); pos.push_back(x + a[1][1] + a[2][2] + a[3][3]); pos.push_back(x + a[1][0] + a[2][1] + a[3][2]); pos.push_back(x + a[0][1] + a[1][2] + a[2][3]); pos.push_back(x + a[0][3] + a[1][2] + a[2][1]); pos.push_back(x + a[1][3] + a[2][2] + a[3][1]); pos.push_back(x + a[0][2] + a[1][1] + a[2][0]); pos.push_back(x + a[1][2] + a[2][1] + a[3][0]); bool t = 0; for (auto i : pos) { if (i == "xx." || i == "x.x" || i == ".xx") t = 1; } if (t) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> bool check(const std::vector<std::vector<char>> &t, int i, int j) { for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (t[i][j] == 'x') { if (t[i - 1][j] == 'x' && t[i + 1][j] == 'x') return true; if (t[i][j - 1] == 'x' && t[i][j + 1] == 'x') return true; if (t[i - 1][j - 1] == 'x' && t[i + 1][j + 1] == 'x') return true; if (t[i + 1][j - 1] == 'x' && t[i - 1][j + 1] == 'x') return true; } } } return false; } int main() { std::vector<std::vector<char>> t(6, std::vector<char>(6, '.')); for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { scanf(" %c", &t[i][j]); } } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (t[i][j] == '.') { t[i][j] = 'x'; if (check(t, i, j)) { printf("YES"); return 0; } t[i][j] = '.'; } } } printf("NO"); return 0; }
#include <bits/stdc++.h> bool horizontal(char t[4][4]) { for (int i = 0; i < 4; i++) { int countx, counts; for (int j = 0; j <= 1; j++) { countx = counts = 0; for (int k = j; k < j + 3; k++) { if (t[i][k] == 'x') { countx++; } else if (t[i][k] == '.') { counts++; } } if (countx == 2 && counts == 1) { return true; } } } return false; } bool right_down_diagonal(char t[4][4]) { int countx, counts; for (int i = 0; i <= 1; i++) { for (int j = 0; j <= 1; j++) { countx = counts = 0; for (int k = 0; k < 3; k++) { if (t[i + k][j + k] == 'x') { countx++; } else if (t[i + k][j + k] == '.') { counts++; } } if (countx == 2 && counts == 1) { return true; } } } return false; } int main() { char chess[4][4]; char transpose[4][4]; char fold[4][4]; char ch; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { scanf("%c", &chess[i][j]); } scanf("%c", &ch); } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { transpose[i][j] = chess[j][i]; fold[i][j] = chess[i][3 - j]; } } bool flag = horizontal(chess); if (!flag) { flag = horizontal(transpose); } if (!flag) { flag = right_down_diagonal(chess); } if (!flag) { flag = right_down_diagonal(fold); } if (flag) { printf("YES\n"); } else { printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; string s[10]; bool flag; bool horizontal() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 2; j++) { if (s[i][j] == 'x') { bool flag = true; for (int k = 0; k < 3; k++) { if (j + k == 4) { flag = false; break; } if (s[i][j + k] != 'x') { flag = false; break; } } if (flag) return true; } } } return false; } bool vertical() { for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == 'x') { bool flag = true; for (int k = 0; k < 3; k++) { if (i + k == 4) { flag = false; break; } if (s[i + k][j] != 'x') { flag = false; break; } } if (flag) return true; } } } return false; } bool diagonal() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == 'x') { bool flag = true; for (int k = 0; k < 3; k++) { if (i + k == 4 or j + k == 4) { flag = false; break; } if (s[i + k][j + k] != 'x') { flag = false; break; } } if (flag) return true; flag = true; for (int k = 0; k < 3; k++) { if (j - k < 0 or i + k == 4) { flag = false; break; } if (s[i + k][j - k] != 'x') { flag = false; break; } } if (flag) return true; } } } return false; } int main() { flag = false; for (int i = 0; i < 4; i++) { cin >> s[i]; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == '.') { s[i][j] = 'x'; flag = horizontal(); if (flag) { break; } flag = vertical(); if (flag) { break; } flag = diagonal(); if (flag) break; s[i][j] = '.'; } } if (flag) break; } if (flag) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> char st[4][4]; int a[4][4]; int main() { for (int i = 0; i < 4; i++) scanf("%s", st[i]); int ok = 0; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { if (st[i][j] == 'x') a[i][j] = 1; else if (st[i][j] == 'o') a[i][j] = -1; else a[i][j] = 0; } for (int i = 0; i < 4; i++) { if (a[i][1] + a[i][2] + a[i][3] == 2) ok = 1; if (a[i][1] + a[i][2] + a[i][0] == 2) ok = 1; } for (int j = 0; j < 4; j++) { if (a[1][j] + a[2][j] + a[3][j] == 2) ok = 1; if (a[1][j] + a[2][j] + a[0][j] == 2) ok = 1; } if (a[2][0] + a[1][1] + a[0][2] == 2) ok = 1; if (a[3][0] + a[2][1] + a[1][2] == 2) ok = 1; if (a[2][1] + a[1][2] + a[0][3] == 2) ok = 1; if (a[3][1] + a[2][2] + a[1][3] == 2) ok = 1; if (a[0][0] + a[1][1] + a[2][2] == 2) ok = 1; if (a[1][1] + a[2][2] + a[3][3] == 2) ok = 1; if (a[1][0] + a[2][1] + a[3][2] == 2) ok = 1; if (a[0][1] + a[1][2] + a[2][3] == 2) ok = 1; if (ok) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> const long long mod = 1000000007; int Inf = (int)2e9; using namespace std; int p[8][8]; bool chech(int x, int y) { if (p[x][2] == 1 && p[x][3] == 1 && p[x][4] == 1) return true; if (p[x][5] == 1 && p[x][3] == 1 && p[x][4] == 1) return true; if (p[2][y] == 1 && p[3][y] == 1 && p[4][y] == 1) return true; if (p[5][y] == 1 && p[3][y] == 1 && p[4][y] == 1) return true; if (p[x - 1][y - 1] == 1 && p[x - 2][y - 2] == 1) return true; if (p[x - 1][y - 1] == 1 && p[x + 1][y + 1] == 1) return true; if (p[x + 2][y + 2] == 1 && p[x + 1][y + 1] == 1) return true; if (p[x - 1][y + 1] == 1 && p[x - 2][y + 2] == 1) return true; if (p[x - 1][y + 1] == 1 && p[x + 1][y - 1] == 1) return true; if (p[x + 1][y - 1] == 1 && p[x + 2][y - 2] == 1) return true; return false; } int main() { memset(p, 0, sizeof(p)); for (int i = 2; i < 6; i++) { for (int j = 2; j < 6; j++) { char c; cin >> c; if (c == 'x') p[i][j] = 1; else if (c == 'o') p[i][j] = -1; } } for (int i = 2; i < 6; i++) { for (int j = 2; j < 6; j++) { if (p[i][j] == 0) { p[i][j] = 1; if (chech(i, j)) { puts("YES"); exit(0); } p[i][j] = 0; } } } puts("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char a[4][4]; cin >> a[0] >> a[1] >> a[2] >> a[3]; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (a[i][j] == 'x') { if (j < 2 && a[i][j + 1] == 'x' && a[i][j + 2] == '.') { cout << "YES"; return 0; } if (j >= 2 && a[i][j - 1] == 'x' && a[i][j - 2] == '.') { cout << "YES"; return 0; } if (i < 2 && a[i + 1][j] == 'x' && a[i + 2][j] == '.') { cout << "YES"; return 0; } if (i >= 2 && a[i - 1][j] == 'x' && a[i - 2][j] == '.') { cout << "YES"; return 0; } if (i >= 2) { if (j >= 2 && a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == '.') { cout << "YES"; return 0; } if (j < 2 && a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == '.') { cout << "YES"; return 0; } } if (i < 2) { if (j >= 2 && a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == '.') { cout << "YES"; return 0; } if (j < 2 && a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == '.') { cout << "YES"; return 0; } } if (j < 2 && a[i][j + 1] == '.' && a[i][j + 2] == 'x') { cout << "YES"; return 0; } if (j >= 2 && a[i][j - 1] == '.' && a[i][j - 2] == 'x') { cout << "YES"; return 0; } if (i < 2 && a[i + 1][j] == '.' && a[i + 2][j] == 'x') { cout << "YES"; return 0; } if (i >= 2 && a[i - 1][j] == '.' && a[i - 2][j] == 'x') { cout << "YES"; return 0; } if (i >= 2) { if (j >= 2 && a[i - 1][j - 1] == '.' && a[i - 2][j - 2] == 'x') { cout << "YES"; return 0; } if (j < 2 && a[i - 1][j + 1] == '.' && a[i - 2][j + 2] == 'x') { cout << "YES"; return 0; } } if (i < 2) { if (j >= 2 && a[i + 1][j - 1] == '.' && a[i + 2][j - 2] == 'x') { cout << "YES"; return 0; } if (j < 2 && a[i + 1][j + 1] == '.' && a[i + 2][j + 2] == 'x') { cout << "YES"; return 0; } } } } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, x, y, z; char a[100][100]; for (i = 0; i <= 8; i++) { for (j = 0; j <= 8; j++) { a[i][j] = 'o'; } } for (i = 3; i <= 6; i++) { cin >> a[i][3] >> a[i][4] >> a[i][5] >> a[i][6]; } for (i = 3; i <= 6; i++) { for (j = 3; j <= 6; j++) { if (a[i][j] == 'x' && (a[i][j + 1] == 'x' && a[i][j + 2] == '.') || a[i][j] == 'x' && (a[i][j + 1] == '.' && a[i][j + 2] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i][j - 1] == 'x' && a[i][j - 2] == '.') || a[i][j] == 'x' && (a[i][j - 1] == '.' && a[i][j - 2] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i - 1][j] == 'x' && a[i - 2][j] == '.') || a[i][j] == 'x' && (a[i - 1][j] == '.' && a[i - 2][j] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i + 1][j] == 'x' && a[i + 2][j] == '.') || a[i][j] == 'x' && (a[i + 1][j] == '.' && a[i + 2][j] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i + 1][j + 1] == 'x' && a[i + 2][j + 2] == '.') || a[i][j] == 'x' && (a[i + 1][j + 1] == '.' && a[i + 2][j + 2] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i + 1][j - 1] == 'x' && a[i + 2][j - 2] == '.') || a[i][j] == 'x' && (a[i + 1][j - 1] == '.' && a[i + 2][j - 2] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i - 1][j + 1] == 'x' && a[i - 2][j + 2] == '.') || a[i][j] == 'x' && (a[i - 1][j + 1] == '.' && a[i - 2][j + 2] == 'x')) { cout << "YES" << endl; break; } else if (a[i][j] == 'x' && (a[i - 1][j - 1] == 'x' && a[i - 2][j - 2] == '.') || a[i][j] == 'x' && (a[i - 1][j - 1] == '.' && a[i - 2][j - 2] == 'x')) { cout << "YES" << endl; break; } } if (j < 7) { break; } } if (i == 7) cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; string s[111]; int dx[4] = {0, 1, 1, 1}; int dy[4] = {1, 0, 1, -1}; bool check() { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { for (int d = 0; d < 4; d++) { bool f = 1; int x = i, y = j; for (int cnt = 0; cnt < 3; cnt++) { if (s[x][y] != 'x') { f = 0; } x += dx[d]; y += dy[d]; } if (f) { return 1; } } } return 0; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; for (int i = 0; i < 4; i++) { cin >> s[i]; s[i] += " "; } for (int i = 4; i < 11; i++) { s[i] = " "; } for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { if (s[i][j] == '.') { s[i][j] = 'x'; if (check()) { cout << "YES\n"; return 0; } s[i][j] = '.'; } } cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; char grid[5][5]; bool inline inside(int i, int j) { return i >= 0 && i < 4 && j >= 0 && j < 4; } int main() { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) cin >> grid[i][j]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { if (grid[i][j] == '.' || grid[i][j] == 'x') { if (inside(i + 1, j) && inside(i + 2, j) && grid[i + 1][j] == 'x' && grid[i + 2][j] == 'x') { cout << "YES" << endl; return 0; } if (inside(i - 1, j) && inside(i - 2, j) && grid[i - 1][j] == 'x' && grid[i - 2][j] == 'x') { cout << "YES" << endl; return 0; } if (inside(i, j + 1) && inside(i, j + 2) && grid[i][j + 1] == 'x' && grid[i][j + 2] == 'x') { cout << "YES" << endl; return 0; } if (inside(i, j - 1) && inside(i, j - 2) && grid[i][j - 1] == 'x' && grid[i][j - 2] == 'x') { cout << "YES" << endl; return 0; } if (inside(i + 1, j + 1) && inside(i + 2, j + 2) && grid[i + 1][j + 1] == 'x' && grid[i + 2][j + 2] == 'x') { cout << "YES" << endl; return 0; } if (inside(i - 1, j - 1) && inside(i - 2, j - 2) && grid[i - 1][j - 1] == 'x' && grid[i - 2][j - 2] == 'x') { cout << "YES" << endl; return 0; } if (inside(i - 1, j + 1) && inside(i - 2, j + 2) && grid[i - 1][j + 1] == 'x' && grid[i - 2][j + 2] == 'x') { cout << "YES" << endl; return 0; } if (inside(i + 1, j - 1) && inside(i + 2, j - 2) && grid[i + 1][j - 1] == 'x' && grid[i + 2][j - 2] == 'x') { cout << "YES" << endl; return 0; } if (inside(i + 1, j) && inside(i - 1, j) && grid[i + 1][j] == 'x' && grid[i - 1][j] == 'x') { cout << "YES" << endl; return 0; } if (inside(i, j + 1) && inside(i, j - 1) && grid[i][j + 1] == 'x' && grid[i][j - 1] == 'x') { cout << "YES" << endl; return 0; } if (inside(i + 1, j + 1) && inside(i - 1, j - 1) && grid[i + 1][j + 1] == 'x' && grid[i - 1][j - 1] == 'x') { cout << "YES" << endl; return 0; } if (inside(i - 1, j + 1) && inside(i + 1, j - 1) && grid[i - 1][j + 1] == 'x' && grid[i + 1][j - 1] == 'x') { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool check(string sub, string a) { string temp1, temp2; temp1 = a[0]; temp1 += a[1]; temp1 += a[2]; temp2 = a[1]; temp2 += a[2]; temp2 += a[3]; if (sub == temp1 || sub == temp2) return true; else return false; } int main() { char a[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { char temp[4]; cin >> a[i][j]; if (i == 2 && (j == 0 || j == 3)) { if (j == 0) { temp[0] = a[0][2]; temp[1] = a[1][1]; temp[2] = a[2][0]; temp[3] = 'o'; } else { temp[0] = a[0][1]; temp[1] = a[1][2]; temp[2] = a[2][3]; temp[3] = 'o'; } } else if (i == 3) { temp[0] = a[0][j]; temp[1] = a[1][j]; temp[2] = a[2][j]; temp[3] = a[3][j]; if (check(".xx", temp) || check("x.x", temp) || check("xx.", temp)) { cout << "YES"; return 0; } if (j == 0) { temp[0] = a[0][3]; temp[1] = a[1][2]; temp[2] = a[2][1]; temp[3] = a[3][0]; } else if (j == 1) { temp[0] = 'o'; temp[1] = a[1][3]; temp[2] = a[2][2]; temp[3] = a[3][1]; } else if (j == 2) { temp[0] = 'o'; temp[1] = a[1][0]; temp[2] = a[2][1]; temp[3] = a[3][2]; } else if (j == 3) { temp[0] = a[0][0]; temp[1] = a[1][1]; temp[2] = a[2][2]; temp[3] = a[3][3]; } } if (check(".xx", temp) || check("x.x", temp) || check("xx.", temp)) { cout << "YES"; return 0; } } if (check(".xx", a[i]) || check("x.x", a[i]) || check("xx.", a[i])) { cout << "YES"; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } const long long N = 1e5; using namespace std; bool check_row(vector<string> v) { for (long long i = 0; i < 4; i++) { string temp = v[i]; for (long long j = 0; j < 4; j++) { if (temp[j] == '.') { temp[j] = 'x'; if (temp.find("xxx") != string::npos) { return true; } temp[j] = '.'; } } } return false; } bool check_diag(string s) { string temp = s; for (long long j = 0; j < 4; j++) { if (temp[j] == '.') { temp[j] = 'x'; if (temp.find("xxx") != string::npos) { return true; } temp[j] = '.'; } } return false; } void solve() { vector<string> v(4); for (long long i = 0; i < 4; i++) { string temp; cin >> temp; v[i] = temp; } bool b1 = check_row(v); vector<string> v2(4); for (long long i = 0; i < 4; i++) { v2[i] = "$$$$"; for (long long j = 0; j < 4; j++) v2[i][j] = v[j][i]; } bool b2 = check_row(v2); if (b1 || b2) { cout << "YES\n"; return; } string s1, s2; for (long long i = 0; i < 4; i++) { s1.push_back(v[i][i]); s2.push_back(v[i][3 - i]); } b1 = check_diag(s1); b2 = check_diag(s2); if (b1 || b2) { cout << "YES\n"; return; } s1[0] = v[0][2]; s1[1] = v[1][1]; s1[2] = v[2][0]; s1[3] = '$'; s2[0] = v[0][1]; s2[1] = v[1][2]; s2[2] = v[2][3]; s2[3] = '$'; b1 = check_diag(s1); b2 = check_diag(s2); if (b1 || b2) { cout << "YES\n"; return; } s1[0] = v[1][3]; s1[1] = v[2][2]; s1[2] = v[3][1]; s1[3] = '$'; s2[0] = v[1][0]; s2[1] = v[2][1]; s2[2] = v[3][2]; s2[3] = '$'; b1 = check_diag(s1); b2 = check_diag(s2); if (b1 || b2) { cout << "YES\n"; return; } cout << "NO\n"; return; cout << "NO\n"; return; } int32_t main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); ; long long t; t = 1; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, a[5][5], sum, add, ex; char c[5][5]; int main() { for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) { cin >> c[i][j]; if (c[i][j] == 'x') { a[i][j] = 4; sum++; } else if (c[i][j] == 'o') { a[i][j] = 1; add++; } } if (sum == add) ex = 8; else ex = 2; for (int i = 1; i <= 4; i++) for (int j = 1; j <= 2; j++) if (a[i][j] + a[i][j + 1] + a[i][j + 2] == ex) { cout << "YES"; return 0; } for (int i = 1; i <= 2; i++) for (int j = 1; j <= 4; j++) if (a[i][j] + a[i + 1][j] + a[i + 2][j] == ex) { cout << "YES"; return 0; } if (a[1][1] + a[2][2] + a[3][3] == ex) { cout << "YES"; return 0; } if (a[2][2] + a[3][3] + a[4][4] == ex) { cout << "YES"; return 0; } if (a[1][4] + a[2][3] + a[3][2] == ex) { cout << "YES"; return 0; } if (a[2][3] + a[3][2] + a[4][1] == ex) { cout << "YES"; return 0; } if (a[3][1] + a[2][2] + a[1][3] == ex) { cout << "YES"; return 0; } if (a[4][2] + a[3][3] + a[2][4] == ex) { cout << "YES"; return 0; } if (a[2][1] + a[3][2] + a[4][3] == ex) { cout << "YES"; return 0; } if (a[1][2] + a[2][3] + a[3][4] == ex) { cout << "YES"; return 0; } cout << "NO"; return 0; }
#include <bits/stdc++.h> int main() { char s[4][4]; for (int i = 0; i < 4; i++) scanf("%s", s[i]); int b = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == '.') { if (i > 0 && s[i - 1][j] == 'x' && i < 3 && s[i + 1][j] == 'x') b = 1; if (j > 0 && s[i][j - 1] == 'x' && j < 3 && s[i][j + 1] == 'x') b = 1; if (j > 0 && i > 0 && s[i - 1][j - 1] == 'x' && j < 3 && i < 3 && s[i + 1][j + 1] == 'x') b = 1; if (j > 0 && i > 0 && j < 3 && i < 3 && s[i - 1][j + 1] == 'x' && s[i + 1][j - 1] == 'x') b = 1; if (i > 1 && s[i - 1][j] == 'x' && s[i - 2][j] == 'x') b = 1; if (j > 1 && s[i][j - 1] == 'x' && s[i][j - 2] == 'x') b = 1; if (i < 2 && s[i + 1][j] == 'x' && s[i + 2][j] == 'x') b = 1; if (j < 2 && s[i][j + 1] == 'x' && s[i][j + 2] == 'x') b = 1; if (i > 1 && j > 1 && s[i - 1][j - 1] == 'x' && s[i - 2][j - 2] == 'x') b = 1; if (i < 2 && j < 2 && s[i + 1][j + 1] == 'x' && s[i + 2][j + 2] == 'x') b = 1; if (i > 1 && j < 2 && s[i - 1][j + 1] == 'x' && s[i - 2][j + 2] == 'x') b = 1; if (i < 2 && j > 1 && s[i + 1][j - 1] == 'x' && s[i + 2][j - 2] == 'x') b = 1; } } } if (b) printf("YES\n"); else printf("NO\n"); }
#include <bits/stdc++.h> using namespace std; void solve() { char cell[6][6]; memset(cell, 'a', sizeof(cell)); for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { cin >> cell[i][j]; } } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (cell[i][j] == '.') { cell[i][j] = 'x'; for (int k = 1; k <= 4; k++) { for (int l = 1; l <= 4; l++) { if (cell[k][l] == 'x') { if ((cell[k][l - 1] == 'x' && cell[k][l + 1] == 'x') || (cell[k - 1][l] == 'x' && cell[k + 1][l] == 'x') || (cell[k - 1][l + 1] == 'x' && cell[k + 1][l - 1] == 'x') || (cell[k - 1][l - 1] == 'x' && cell[k + 1][l + 1] == 'x')) { cout << "YES\n"; return; } } } } cell[i][j] = '.'; } } } cout << "NO\n"; return; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; bool vis[4][4]; queue<pair<int, int> > q; vector<pair<int, int> > v; int main() { pair<int, int> p; long long i, j, k, l, m, n, x, y; long long arr[4][4]; char c; bool f = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { cin >> c; arr[i][j] = c; } } for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (arr[i][j] == 'x') { if ((j + 1 < 4 && arr[i][j + 1] == 'x' && j + 2 < 4 && arr[i][j + 2] == '.') || (j + 1 < 4 && arr[i][j + 1] == '.' && j + 2 < 4 && arr[i][j + 2] == 'x')) cout << "YES", f = 1; else if ((j - 1 >= 0 && arr[i][j - 1] == 'x' && j - 2 >= 0 && arr[i][j - 2] == '.') || (j - 1 >= 0 && arr[i][j - 1] == '.' && j - 2 >= 0 && arr[i][j - 2] == 'x')) cout << "YES", f = 1; else if ((i + 1 < 4 && arr[i + 1][j] == 'x' && i + 2 < 4 && arr[i + 2][j] == '.') || (i + 1 < 4 && arr[i + 1][j] == '.' && i + 2 < 4 && arr[i + 2][j] == 'x')) cout << "YES", f = 1; else if ((i - 1 >= 0 && arr[i - 1][j] == 'x' && i - 2 >= 0 && arr[i - 2][j] == '.') || (i - 1 >= 0 && arr[i - 1][j] == '.' && i - 2 >= 0 && arr[i - 2][j] == 'x')) cout << "YES", f = 1; else if ((i + 1 < 4 && j + 1 < 4 && arr[i + 1][j + 1] == 'x' && i + 2 < 4 && j + 2 < 4 && arr[i + 2][j + 2] == '.') || (i + 1 < 4 && j + 1 < 4 && arr[i + 1][j + 1] == '.' && i + 2 < 4 && j + 2 < 4 && arr[i + 2][j + 2] == 'x')) cout << "YES", f = 1; else if ((i + 1 < 4 && j - 1 >= 0 && j - 1 < 4 && arr[i + 1][j - 1] == 'x' && i + 2 < 4 && j - 2 >= 0 && j - 2 < 4 && arr[i + 2][j - 2] == '.') || (i + 1 < 4 && j - 1 >= 0 && j - 1 < 4 && arr[i + 1][j - 1] == '.' && i + 2 < 4 && j - 2 >= 0 && j - 2 < 4 && arr[i + 2][j - 2] == 'x')) cout << "YES", f = 1; else if ((i - 1 >= 0 && j - 1 >= 0 && arr[i - 1][j - 1] == 'x' && i - 2 >= 0 && j - 2 >= 0 && arr[i - 2][j - 2] == '.') || (i - 1 >= 0 && j - 1 >= 0 && arr[i - 1][j - 1] == '.' && i - 2 >= 0 && j - 2 >= 0 && arr[i - 2][j - 2] == 'x')) cout << "YES", f = 1; else if ((i - 1 >= 0 && j + 1 < 4 && arr[i - 1][j + 1] == 'x' && i - 2 >= 0 && j + 2 < 4 && arr[i - 2][j + 2] == '.') || (i - 1 >= 0 && j + 1 < 4 && arr[i - 1][j + 1] == '.' && i - 2 >= 0 && j + 2 < 4 && arr[i - 2][j + 2] == 'x')) cout << "YES", f = 1; } if (f) return 0; } } if (!f) cout << "NO"; }
#include <bits/stdc++.h> using namespace std; string s[10]; int main() { ios::sync_with_stdio(false); s[0] = "........"; s[1] = s[0]; s[6] = s[0]; s[7] = s[0]; for (int i = 2; i <= 5; i++) { cin >> s[i]; s[i] = ".." + s[i] + ".."; } for (int i = 2; i <= 5; i++) { for (int j = 2; j <= 5; j++) { if (s[i][j] != '.') continue; if (s[i - 1][j] == 'x' && s[i + 1][j] == 'x') { cout << "YES\n"; return 0; } if (s[i][j - 1] == 'x' && s[i][j + 1] == 'x') { cout << "YES\n"; return 0; } if (s[i - 1][j - 1] == 'x' && s[i + 1][j + 1] == 'x') { cout << "YES\n"; return 0; } if (s[i - 1][j + 1] == 'x' && s[i + 1][j - 1] == 'x') { cout << "YES\n"; return 0; } if (s[i][j - 1] == 'x' && s[i][j - 2] == 'x') { cout << "YES\n"; return 0; } if (s[i - 1][j] == 'x' && s[i - 2][j] == 'x') { cout << "YES\n"; return 0; } if (s[i - 1][j - 1] == 'x' && s[i - 2][j - 2] == 'x') { cout << "YES\n"; return 0; } if (s[i + 1][j - 1] == 'x' && s[i + 2][j - 2] == 'x') { cout << "YES\n"; return 0; } if (s[i][j + 1] == 'x' && s[i][j + 2] == 'x') { cout << "YES\n"; return 0; } if (s[i + 1][j + 1] == 'x' && s[i + 2][j + 2] == 'x') { cout << "YES\n"; return 0; } if (s[i + 1][j] == 'x' && s[i + 2][j] == 'x') { cout << "YES\n"; return 0; } if (s[i][j + 1] == 'x' && s[i][j + 2] == 'x') { cout << "YES\n"; return 0; } if (s[i - 1][j + 1] == 'x' && s[i - 2][j + 2] == 'x') { cout << "YES\n"; return 0; } } } cout << "NO\n" << endl; }
#include <bits/stdc++.h> using namespace std; string tic[4]; int arr[4][4]; int main() { ios_base::sync_with_stdio(false); for (int i = 0; i < 4; i++) cin >> tic[i]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (tic[i][j] == 'x') arr[i][j] = 1; else if (tic[i][j] == 'o') arr[i][j] = -1; else arr[i][j] == 0; } } int flag = 0; int sum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 2; j++) { sum = 0; for (int k = j; k < j + 3; k++) { sum += arr[i][k]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 2; j++) { sum = 0; for (int k = j; k < j + 3; k++) { sum += arr[k][i]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } } } for (int i = 0; i < 2; i++) { sum = 0; for (int j = i; j < i + 3; j++) { sum += arr[j][j]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } sum = 0; for (int j = i; j < i + 3; j++) { sum += arr[j][3 - j]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } } sum = 0; for (int i = 1; i < 4; i++) { sum += arr[i][i - 1]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } sum = 0; for (int i = 1; i < 4; i++) { sum += arr[i][4 - i]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } sum = 0; for (int i = 0; i < 3; i++) { sum += arr[i][i + 1]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } sum = 0; for (int i = 0; i < 3; i++) { sum += arr[i][2 - i]; } if (sum == 2) { flag = 1; cout << "YES" << endl; return 0; } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char A[15][15]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); memset(A, 0, sizeof(A)); for (int i = 5; i < 9; ++i) cin >> (A[i] + 5); for (int i = 5; i < 9; ++i) for (int j = 5; j < 9; ++j) { { int x = 0; int d = 0; for (int k = 0; k < 3; ++k) { x += A[i + k][j + k] == 'x'; d += A[i + k][j + k] == '.'; } if (x == 2 && d) return cout << "YES" << endl, 0; } { int x = 0; int d = 0; for (int k = 0; k < 3; ++k) { x += A[i - k][j + k] == 'x'; d += A[i - k][j + k] == '.'; } if (x == 2 && d) return cout << "YES" << endl, 0; } { int x = 0; int d = 0; for (int k = 0; k < 3; ++k) { x += A[i + k][j] == 'x'; d += A[i + k][j] == '.'; } if (x == 2 && d) return cout << "YES" << endl, 0; } { int x = 0; int d = 0; for (int k = 0; k < 3; ++k) { x += A[i][j + k] == 'x'; d += A[i][j + k] == '.'; } if (x == 2 && d) return cout << "YES" << endl, 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char a[4][4]; int i, j, k, l, c = 0; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) cin >> a[i][j]; for (i = 0, c = 0; i < 4; i++) for (j = 0; j < 4; j++) { if (a[i][j] == 'x') { if (j <= 1) { if (a[i][j + 1] == 'x') { if (a[i][j + 2] == '.') { c = 5; break; } } } if (j >= 2) { if (a[i][j - 1] == 'x') { if (a[i][j - 2] == '.') { c = 5; break; } } } } } if (c == 0) { for (j = 0; j < 4; j++) for (i = 0; i < 4; i++) { if (a[i][j] == 'x') { if (i <= 1) { if (a[i + 1][j] == 'x') { if (a[i + 2][j] == '.') { c = 5; break; } } } if (i >= 2) { if (a[i - 1][j] == 'x') { if (a[i - 2][j] == '.') { c = 5; break; } } } } } } if (c == 0) { for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { if (i <= 1) { if (a[i][j] == 'x') { if (a[i + 2][j] == 'x') { if (a[i + 1][j] == '.') { c = 5; break; } } } } if (i >= 2) { if (a[i][j] == 'x') { if (a[i - 2][j] == 'x') { if (a[i - 1][j] == '.') { c = 5; break; } } } } } } if (c == 0) { for (j = 0; j < 4; j++) for (i = 0; i < 4; i++) { if (i <= 1) { if (a[j][i] == 'x') { if (a[j][i + 2] == 'x') { if (a[j][i + 1] == '.') { c = 5; break; } } } } } } if (c == 0) { for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { if (c == 5) break; if (a[i][j] == 'x') { if (j <= 1 && i <= 1) { if (a[i + 1][j + 1] == 'x') { if (a[i + 2][j + 2] == '.') { c = 5; break; } } if (a[i + 1][j + 1] == '.') { if (a[i + 2][j + 2] == 'x') { c = 5; break; } } } } if (c == 0) { if (i <= 1 && j <= 1) { if (a[i][j + 2] == 'x') { if (a[i + 1][j + 1] == 'x') { if (a[i + 2][j] == '.') { c = 5; break; } } if (a[i + 1][j + 1] == '.') { if (a[i + 2][j] == 'x') { c = 5; break; } } } } } if (a[i][j] == '.') { if (j <= 1 && i >= 2) { if (a[i - 1][j + 1] == 'x') { if (a[i - 2][j + 2] == 'x') { c = 5; break; } } } if (j >= 2 && i <= 1) { if (a[i + 1][j - 1] == 'x') { if (a[i + 2][j - 2] == 'x') { c = 5; break; } } } if (j >= 2 && i >= 2) { if (a[i - 1][j - 1] == 'x') { if (a[i - 2][j - 2] == 'x') { c = 5; break; } } } if (j <= 1 && i <= 1) { if (a[i + 1][j + 1] == 'x') { if (a[i + 2][j + 2] == 'x') { c = 5; break; } } } } } } if (c == 5) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool inGrid(int x, int y) { return (x < 4 && x >= 0 && y < 4 && y >= 0); } int main() { char grid[4][4]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) cin >> grid[i][j]; const int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; const int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1}; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { if (grid[i][j] != '.') continue; grid[i][j] = 'x'; for (int I = 0; I < 4; I++) for (int J = 0; J < 4; J++) for (int dir = 0; dir < 8; dir++) { bool won = true; for (int k = 0; k < 3; k++) { if (!inGrid(I + k * dx[dir], J + k * dy[dir])) won = false; else if (grid[I + k * dx[dir]][J + k * dy[dir]] != 'x') won = false; } if (won) { cout << "YES" << endl; return 0; } } grid[i][j] = '.'; } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; char s[10][10]; int ii; int fl = 0; void pan() { char ch; if (ii & 1) ch = 'x'; else ch = 'o'; for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) if (s[i][j] == ch) { if (j <= 2) { if (s[i][j + 1] == ch && s[i][j + 2] == ch) { fl = 1; return; } } if (i <= 2) { if (s[i + 1][j] == ch && s[i + 2][j] == ch) { fl = 1; return; } } if (i <= 2 && j <= 2) { if (s[i + 1][j + 1] == ch && s[i + 2][j + 2] == ch) { fl = 1; return; } } if (i <= 2 && j >= 3) { if (s[i + 1][j - 1] == ch && s[i + 2][j - 2] == ch) { fl = 1; return; } } } } void work(int play, int d) { if (d == 0) { pan(); return; } for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) if (s[i][j] == '.') { if (!play) s[i][j] = 'x'; else s[i][j] = 'o'; work(play ^ 1, d - 1); s[i][j] = '.'; } return; } int main() { for (int i = 1; i <= 4; i++) scanf("%s", s[i] + 1); for (ii = 1; ii <= 1; ii++) { work(0, ii); if (fl) { printf("YES\n"); } else printf("NO\n"); } }
#include <bits/stdc++.h> char s[10][10]; bool check() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 2; j++) { if (s[i][j] == 'x' && s[i][j + 1] == 'x' && s[i][j + 2] == 'x') { return 1; } } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == 'x' && s[i + 1][j] == 'x' && s[i + 2][j] == 'x') { return 1; } } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { if (s[i][j] == 'x' && s[i + 1][j + 1] == 'x' && s[i + 2][j + 2] == 'x') { return 1; } if (s[i][j + 2] == 'x' && s[i + 1][j + 1] == 'x' && s[i + 2][j] == 'x') { return 1; } } } return 0; } bool solve() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (s[i][j] == '.') { s[i][j] = 'x'; if (check()) { return 1; } s[i][j] = '.'; } } } return 0; } int main() { scanf("%s%s%s%s", s[0], s[1], s[2], s[3]); puts(solve() ? "YES" : "NO"); return 0; }
#include <bits/stdc++.h> int main(void) { int Count, Number; char E[5]; scanf("%d", &Number); gets(E); char String[Number + 1]; gets(String); for (Count = 0; Count < Number; Count++) { if (String[Count] != 'a' && String[Count] != 'e' && String[Count] != 'i' && String[Count] != 'o' && String[Count] != 'u' && String[Count] != 'y') printf("%c", String[Count]); else { if (String[Count] != String[Count - 1]) printf("%c", String[Count]); if ((String[Count] == 'e' || String[Count] == 'o') && String[Count - 1] == String[Count] && String[Count - 2] != String[Count] && String[Count + 1] != String[Count]) printf("%c", String[Count]); } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); std::ios::sync_with_stdio(false); int n; cin >> n; int used[n]; for (int i = 0; i < n; i++) { used[i] = 0; } string s; cin >> s; int i = 0; while (i < s.length()) { if (s[i] == 'e' && (i + 1 < n && s[i + 1] == 'e') && ((i - 1 > -1 && s[i - 1] != 'e') || i - 1 <= -1) && ((i + 2 < n && s[i + 2] != 'e') || i + 2 >= n)) { used[i] = 1; used[i + 1] = 1; i += 1; } else if (s[i] == 'o' && (i + 1 < n && s[i + 1] == 'o') && ((i - 1 > -1 && s[i - 1] != 'o') || i - 1 <= -1) && ((i + 2 < n && s[i + 2] != 'o') || i + 2 >= n)) { used[i] = 1; used[i + 1] = 1; i += 1; } i++; } int j = 1; while (j < s.length()) { if (used[j] == 1) { j++; } else { if (s[j] == s[j - 1] && (s[j] == 'i' || s[j] == 'y' || s[j] == 'u' || s[j] == 'o' || s[j] == 'e' || s[j] == 'a')) { used[j] = 2; } j++; } } for (int i = 0; i < n; i++) { if (used[i] != 2) { cout << s[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 1e5 + 10; char a[maxn]; int v[maxn], b[200]; int main() { int n; b['e'] = b['a'] = b['i'] = b['o'] = b['u'] = b['y'] = 1; scanf("%d", &n); scanf("%s", a); for (int i = 0; i < n; i++) { if (b[a[i]] == 0) printf("%c", a[i]); else if ((a[i] == 'e' && a[i + 1] == 'e' && a[i + 2] != 'e') || (a[i] == 'o' && a[i + 1] == 'o' && a[i + 2] != 'o')) { printf("%c%c", a[i], a[i + 1]); i++; } else { printf("%c", a[i]); while (a[i] == a[i + 1]) i++; } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n, i, j, c = 0, d = 1; cin >> n; char a[6] = {'a', 'e', 'i', 'o', 'u', 'y'}, h; string s; cin >> s; for (i = 0; i < n; i++) { if (d == 0) { if (s[i] == h) c++; else { if (c >= 1) { if ((h == 'e' || h == 'o') && c == 1) { if (c == 1) cout << h << h; } else cout << h; } else cout << h; d = 1; c = 0; } } if (d) { for (j = 0; j < 6; j++) if (s[i] == a[j]) { d = 0; h = a[j]; break; } if (j == 6) cout << s[i]; } } if (!d) { if (c >= 1) { if ((h == 'e' || h == 'o') && c == 1) { if (c == 1) cout << h << h; } else cout << h; } else cout << h; } return 0; }
#include <bits/stdc++.h> using namespace std; int const M = 1 << 16; int md = 1e9 + 7; int i, j, n, m, N, t, x, y, k, nom; int main() { cin >> n; string s, s1; cin >> s; for (int i = 0; i < n; i++) if (s[i] == 'a' || s[i] == 'o' || s[i] == 'e' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { int j = i; while (j < n && s[i] == s[j]) j++; if (j - i == 2 && (s[i] == 'e' || s[i] == 'o')) s1 = s1 + s[i] + s[i]; else s1 += s[i]; i = j - 1; } else { s1 += s[i]; } cout << s1; }
#include <bits/stdc++.h> using namespace std; set<char> vowel{'u', 'e', 'o', 'a', 'i', 'y'}; bool check(string foo) { return (foo.size() == 2 && (foo[0] == 'e' || foo[0] == 'o')); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; string s; cin >> n >> s; s += 'z'; string foo = "", ans = ""; for (char c : s) { if (vowel.count(c)) { if (foo == "" || foo[0] == c) { foo += c; } else { ans += foo[0]; if (check(foo)) ans += foo[0]; foo = ""; foo += c; } } else { if (foo != "") { ans += foo[0]; if (check(foo)) ans += foo[0]; } foo = ""; ans += c; } } ans.pop_back(); cout << ans; }
#include <bits/stdc++.h> int arrv[100005]; int n, y = -1, i; char x, ant, arrc[100005]; int main() { scanf("%d", &n); for (i = 0; i < n; i++) { scanf(" %c", &x); if (i > 0 && ant == x) { arrv[y]++; } else { y++; arrc[y] = x; arrv[y] = 1; } ant = x; } for (i = 0; i <= y; i++) { if ((arrc[i] != 'a' && arrc[i] != 'e' && arrc[i] != 'i' && arrc[i] != 'o' && arrc[i] != 'u' && arrc[i] != 'y') || ((arrc[i] == 'e' || arrc[i] == 'o') && arrv[i] == 2)) { while (arrv[i] > 0) { printf("%c", arrc[i]); arrv[i]--; } } else { printf("%c", arrc[i]); } } return 0; }
#include <bits/stdc++.h> char s[100001]; int N; int main() { scanf("%d%s", &N, s); for (int i = 0, j; i < N; i = j) { j = i + 1; while (j < N && s[i] == s[j]) j++; if (s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y' || (s[i] == 'e' || s[i] == 'o') && j - i != 2) putchar(s[i]); else for (int T = j - i; T--;) putchar(s[i]); } putchar('\n'); return 0; }
#include <bits/stdc++.h> using namespace std; char str[100010]; int is(char c) { char s[] = "aeiouy"; for (int i = 0; i < 6; i++) { if (c == s[i]) return 1; } return 0; } int main() { memset(str, 0, sizeof(str)); int n; int hold_flag = 0; char c = ' '; cin >> n >> str; for (int i = 0; i < n; i++) { if (i > 0 && !is(c)) { cout << c; hold_flag = 0; c = str[i]; continue; } if (i > 0 && c != str[i]) { if (hold_flag == 1 && (c == 'e' || c == 'o')) cout << c; cout << c; hold_flag = 0; } if (c == str[i]) { hold_flag++; } c = str[i]; } if (hold_flag == 1 && (c == 'e' || c == 'o')) cout << c; cout << c << endl; }
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)1e5 + 5; char str[MAXN]; char ans[MAXN]; bool check(int x) { if (str[x] == 'a' || str[x] == 'e' || str[x] == 'i' || str[x] == 'o' || str[x] == 'u' || str[x] == 'y') return true; return false; } int main() { int n; scanf("%d", &n); scanf("%s", str); int u(0), v(0); while (u < n) { if (check(u)) { int num(1); while (u + 1 < n && str[u + 1] == str[u]) { ++u; ++num; } ans[v++] = str[u]; if (num == 2 && (str[u] == 'e' || str[u] == 'o')) ans[v++] = str[u]; ++u; } else { ans[v++] = str[u++]; } } ans[v++] = '\0'; printf("%s\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; string s; char ch; cin >> s; int vowel = 0, count = 0; string s2 = ""; for (int i = 0; i < s.size();) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { ch = s[i]; i++; count++; while (ch == s[i] && i < s.size()) { i++; count++; } if (count == 2 && (ch == 'e' || ch == 'o')) { s2 = s2 + ch + ch; count = 0; } else { s2 = s2 + ch; count = 0; } } else { s2 = s2 + s[i]; count = 0; i++; } } cout << s2 << endl; }
#include <bits/stdc++.h> using namespace std; int n; string s; vector<char> ans; int f(int i) { int j = i; while (j != n && s[i] == s[j]) j++; return j - i; } int main() { scanf("%d", &n); cin >> s; for (int i = 0; i < (n); i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { if (s[i] == 'e' || s[i] == 'o') { if (f(i) == 2) { ans.push_back(s[i]); ans.push_back(s[i]); i++; } else { ans.push_back(s[i]); i += f(i) - 1; } } else { ans.push_back(s[i]); i += f(i) - 1; } } else { ans.push_back(s[i]); } } for (int i = 0; i < (ans.size()); i++) { printf("%c", ans[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; set<char> vowel = {'a', 'e', 'i', 'o', 'u', 'y'}; set<char> special_vowel = {'e', 'o'}; for (int i = 0; i < n; ++i) { if (vowel.find(s[i]) == vowel.end()) { cout << s[i]; } else { int len = 0; while (i + len < n and s[i] == s[i + len]) { ++len; } if (len == 2 and special_vowel.find(s[i]) != special_vowel.end()) { cout << s[i] << s[i]; ++i; } else { cout << s[i]; i += len - 1; } } } }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; int main() { string s, ans; int x = 0, y = 0, n; cin >> n; cin >> s; s += ' '; for (int i = 0; i < n; i++) { if (s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { if (i == 0) { ans.push_back(s[i]); } else if (s[i] != s[i - 1]) { ans.push_back(s[i]); } x = 0; y = 0; } else if (s[i] == 'o') { y = 0; if (x == 0) { ans.push_back(s[i]); } if (x == 1) { if (s[i] == s[i - 1] && s[i] != s[i + 1]) { ans.push_back(s[i]); } } x++; } else if (s[i] == 'e') { x = 0; if (y == 0) { ans.push_back(s[i]); } if (y == 1) { if (s[i] == s[i - 1] && s[i] != s[i + 1]) { ans.push_back(s[i]); } } y++; } else { x = 0; y = 0; ans.push_back(s[i]); } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { ios::sync_with_stdio(0); cin.tie(0); int n, c_e = 0, c_o = 0; char c; cin >> n; vector<char> v(n + 4); bool e, o; for (int i = 1; i <= n; i++) { cin >> c; v[i] = c; if (c == v[i - 1] && c == 'e') e = true; if (c == v[i - 1] && c == 'o') o = true; } for (int i = 1; i <= n; i++) { if ((v[i] == v[i + 1]) && (v[i] != v[i - 1]) && (v[i] != v[i + 2]) && (v[i] == 'o') && o) { cout << v[i] << v[i + 1]; i++; continue; } if ((v[i] == v[i + 1] && (v[i] != v[i - 1]) && v[i] != v[i + 2]) && (v[i] == 'e') && e) { cout << v[i] << v[i + 1]; i++; continue; } if ((v[i] == v[i + 1]) && (v[i] == 'a' || v[i] == 'e' || v[i] == 'i' || v[i] == 'o' || v[i] == 'u' || v[i] == 'y')) { cout << v[i]; while (v[i] == v[i + 1]) { i++; } } else { cout << v[i]; } } return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:100000000") #pragma GCC optimize("O3") using namespace std; const bool db = false; int main() { int n; string s; string res = ""; cin >> n >> s; int j; for (int i = 0; i < n; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { j = i; while (s[i] == s[j]) j++; if (j - i == 2 && (s[i] == 'e' || s[i] == 'o')) while (i != j) res += s[i++]; else res += s[i], i = j; i--; } else res += s[i]; } cout << res << '\n'; return 0; }
#include <bits/stdc++.h> int main() { long n, e = 0; scanf("%d", &n); char c[n + 1]; scanf("%s", c); c[n] = '#'; printf("%c", c[e]); for (long i = 1; i < n; i++) if (c[i] != 'a' && c[i] != 'e' && c[i] != 'i' && c[i] != 'o' && c[i] != 'u' && c[i] != 'y') printf("%c", c[i]); else if (c[i] != c[i - 1] || (((c[i] == 'e') || c[i] == 'o') && (c[i] != c[i + 1] && c[i - 2] != c[i]))) printf("%c", c[i]); }
#include <bits/stdc++.h> using namespace std; int main() { int n; string a; cin >> n; cin >> a; cout << a[0]; char ch = a[0]; int r = 1; for (int i = 1; i < n; i++) { if ((a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u' || a[i] == 'y') && a[i] == ch) { r++; } else { if ((ch == 'e' || ch == 'o') && r == 2) { cout << ch; } cout << a[i]; ch = a[i]; r = 1; } } if ((a[n - 1] == 'e' || a[n - 1] == 'o') && r == 2) cout << a[n - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; vector<string> split(string s) { vector<string> vec; string str = ""; str += s[0]; long long n = 1; for (long long i = 1; i < s.length(); i++) { if (str[str.length() - 1] == s[i]) str += s[i]; else { vec.push_back(str); str = ""; str += s[i]; } } vec.push_back(str); return vec; } signed main() { long long n; cin >> n; string s; cin >> s; long long i; vector<string> vec = split(s); for (i = 0; i < vec.size(); i++) { if (vec[i].size() == 1) cout << vec[i]; else if (vec[i].size() == 2) { if (vec[i][0] == 'a' || vec[i][0] == 'i' || vec[i][0] == 'u' || vec[i][0] == 'y') cout << vec[i][0]; else cout << vec[i]; } else { if (vec[i][0] == 'a' || vec[i][0] == 'e' || vec[i][0] == 'i' || vec[i][0] == 'o' || vec[i][0] == 'u' || vec[i][0] == 'y') cout << vec[i][0]; else cout << vec[i]; } } }
#include <bits/stdc++.h> using namespace std; long long int pow_mod(long long int a, long long int b) { long long int res = 1; while (b != 0) { if (b & 1) { res = (res * a) % 1000000007; } a = (a * a) % 1000000007; b /= 2; } return res; } void solve() { long long int n; cin >> n; string s; cin >> s; string ans; bool flag1 = false; bool flag2 = false; long long int sz = 0; for (long long int i = 0; i < n; i++) { if (s[i] == 'e') { sz = 0; while (i < n && s[i] == 'e') { sz++; i++; } if (sz == 2) { flag1 = true; break; } } } for (long long int i = 0; i < n; i++) { if (s[i] == 'o') { sz = 0; while (s[i] == 'o') { sz++; i++; } if (sz == 2) { flag2 = true; break; } } } for (long long int i = 0; i < n; i++) { ans += s[i]; if (s[i] == 'a' || s[i] == 'e' || s[i] == 'o' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { char x = s[i]; sz = 0; while (i < n && s[i] == x) { i++; sz++; } if ((flag1 || flag2) && (x == 'e' || x == 'o') && sz == 2) ans += x; i--; } } cout << ans << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; t = 1; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const long long int MAXX = 1e5 + 1; const long long int MOD = 1e9 + 7; int main() { std::ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, i; cin >> n; char s[n + 1]; cin >> s; for (i = 0; i < n; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { long long int j = i; char ch; ch = s[i]; while (s[j] == ch) j++; if ((ch == 'e' || ch == 'o') && (j - i) == 2) cout << ch << ch; else cout << ch; i = j; i--; } else cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int i, n, t, a[1000001]; string s; int main() { cin >> n >> s; for (i = 0; i < n - 1; i++) { if ((s[i] == 'e' && s[i + 1] == 'e' && s[i - 1] != 'e' && s[i + 2] != 'e') || (s[i] == 'o' && s[i + 1] == 'o' && s[i - 1] != 'o' && s[i + 2] != 'o')) t++; else { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { if (s[i + 1] == s[i]) { a[i + 1]++; } } } } for (i = 0; i < n; i++) { if (a[i] == 0) cout << s[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { int c, k, n, i; char s[100010]; cin >> n; for (i = 1; i <= n; i++) { cin >> s[i]; } i = 1; while (i < n) { if ((s[i] == 'a') || (s[i] == 'i') || (s[i] == 'u') || (s[i] == 'y')) { k = 1; c = i; c++; while (s[c] == s[i]) { k++; s[c] = '1'; c++; } i = c; } else if ((s[i] == 'e') || (s[i] == 'o')) { k = 1; c = i; c++; while (s[c] == s[i]) { k++; if (k > 2) { s[c] = '1'; s[c - 1] = '1'; } c++; } i = c; } else i++; } for (i = 1; i <= n; i++) { if (s[i] != '1') cout << s[i]; } cout << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { long int n, count = 0; cin >> n; string s; cin >> s; char k; for (long int i = 0; i < n; i++) { count = 0; if (s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { k = s[i]; for (long int j = i + 1; j < n; j++) { if (s[j] == k) s[j] = '1'; else break; } } if (s[i] == 'e' || s[i] == 'o') { k = s[i]; for (long int j = i + 1; j < n; j++) { if (s[j] == k) { count++; s[j] = '1'; } else { if (count == 1) { s[j - 1] = k; } count = 0; break; } } if (count == 1) s[n - 1] = k; } } for (long int i = 0; i < n; i++) { if (s[i] != '1') cout << s[i]; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int n; char s[111111]; vector<char> cs; string res; int main() { cin.sync_with_stdio(false); cin >> n >> s; cs.push_back('a'); cs.push_back('e'); cs.push_back('i'); cs.push_back('o'); cs.push_back('u'); cs.push_back('y'); for (int i = (int)(0); i < (int)(n); i++) { res += s[i]; if (i < n - 1 && s[i] == 'e' && s[i + 1] == 'e' && s[i + 2] != 'e') continue; if (i < n - 1 && s[i] == 'o' && s[i + 1] == 'o' && s[i + 2] != 'o') continue; if ((find((cs).begin(), (cs).end(), s[i]) != cs.end())) { char c = s[i]; while (i < n && s[i] == c) i++; i--; } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool isVowel(char c) { return (c == 'a' || c == 'u' || c == 'e' || c == 'i' || c == 'y' || c == 'o'); } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; string s, res; cin >> n >> s; int arr[26] = {0}; for (int i = 0; i < s.size(); i++) { if (s[i] != s[i + 1]) { res += s[i]; for (int k = 0; k < 26; k++) { if ((arr[k] == 1) && (s[i] == 'o' || s[i] == 'e')) { res += ('a' + k); break; } } arr[s[i] - 97] = 0; } else if (s[i] == s[i + 1]) { if (!isVowel(s[i])) res += s[i]; else arr[s[i] - 'a']++; } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { ios::sync_with_stdio(0); cin.tie(0); int n, c_e = 0, c_o = 0; char c; cin >> n; vector<char> v(n + 4); bool e, o; for (int i = 1; i <= n; i++) { cin >> c; v[i] = c; } for (int i = 1; i <= n; i++) { if ((v[i] == v[i + 1]) && (v[i] != v[i - 1]) && (v[i] != v[i + 2]) && (v[i] == 'o')) { cout << v[i] << v[i + 1]; i++; continue; } if ((v[i] == v[i + 1] && (v[i] != v[i - 1]) && v[i] != v[i + 2]) && (v[i] == 'e')) { cout << v[i] << v[i + 1]; i++; continue; } if ((v[i] == v[i + 1]) && (v[i] == 'a' || v[i] == 'e' || v[i] == 'i' || v[i] == 'o' || v[i] == 'u' || v[i] == 'y')) { cout << v[i]; while (v[i] == v[i + 1]) { i++; } } else { cout << v[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; const int limN = 1e5 + 5; int N; char str[limN]; bool isvow[300]; int main() { int cnt = 0, tp; isvow['a'] = isvow['e'] = isvow['i'] = isvow['o'] = isvow['u'] = isvow['y'] = true; scanf("%d%s", &N, str); tp = str[0]; for (int i = 0; i <= N; i++) { if (tp != str[i]) { if ((tp == 'e' || tp == 'o') && cnt == 2) printf("%c%c", tp, tp); else if (isvow[tp]) printf("%c", tp); else { for (int j = 0; j < cnt; j++) printf("%c", tp); } cnt = 0; } tp = str[i]; cnt++; } printf("\n"); }
#include <bits/stdc++.h> using namespace std; int n, i; string s, c = "#"; stack<char> st, tt; int main() { cin >> n >> s; s = '/' + s; s = s + '/'; for (i = 1; i <= s.size() - 3; i++) { if (s[i] == s[i + 1] && s[i] != s[i - 1] && s[i] != s[i + 2] && (s[i] == 'o' || s[i] == 'e')) { s.insert(i + 1, c); i++; } } for (i = 0; i < s.size(); i++) { st.push(s[i]); } tt.push(st.top()); st.pop(); while (!st.empty()) { if (tt.top() == st.top() && (tt.top() == 'a' || tt.top() == 'e' || tt.top() == 'i' || tt.top() == 'o' || tt.top() == 'u' || tt.top() == 'y')) st.pop(); else { tt.push(st.top()); st.pop(); } } while (!tt.empty()) { if (tt.top() == '#' || tt.top() == '/') tt.pop(); else { cout << tt.top(); tt.pop(); } } }
#include <bits/stdc++.h> int main() { int n; scanf("%d\n", &n); char s[n + 2]; for (int i = 0; i < n; ++i) { scanf("%c", &s[i]); } s[n] = 0; char lc = 0, lcc = 1, cur, nx = 0; for (int i = 0; i < n; ++i) { cur = s[i]; nx = s[i + 1]; if (i > 0) { lc = s[i - 1]; if (lc == cur && (cur != 'o' && cur != 'e')) { if (cur == 'a' || cur == 'i' || cur == 'u' || cur == 'y') continue; } if (lc == cur && cur == nx && (cur == 'o' || cur == 'e')) { continue; } } if (i > 1) { lcc = s[i - 2]; if (lc == cur && cur == lcc && (cur == 'o' || cur == 'e')) { continue; } } printf("%c", cur); } printf("\n"); }
#include <bits/stdc++.h> using namespace std; int main() { int i = 0, n; string s, s1, s2; cin >> n; cin >> s; while (i < n) { s2 = s[i]; i++; while ((i != n) and (s[i] == s[i - 1])) { s2 += s[i]; i++; } i--; if ((s[i] == 'a') or (s[i] == 'o') or (s[i] == 'i') or (s[i] == 'u') or (s[i] == 'y') or (s[i] == 'e')) { s1 += s2[0]; if ((s2.size() == 2) and ((s[i] == 'e') or (s[i] == 'o'))) s1 += s[i]; } else s1 += s2; i++; } cout << s1; }
#include <bits/stdc++.h> int main() { int n; char str[100005]; int dp[100005]; scanf("%d\n", &n); for (int i = 0; i < n;) { scanf("%c", &str[i]); i = i + 1; } dp[n - 1] = 1; for (int i = n - 2; i >= 0;) { if (str[i] == str[i + 1]) dp[i] = dp[i + 1] + 1; else dp[i] = 1; i = i - 1; } int j = 0; while (j < n) { if (str[j] == 'a') { printf("%c", str[j]); j = j + dp[j]; } else if (str[j] == 'e') { if (dp[j] == 2) { printf("%c%c", str[j], str[j]); j = j + 2; } else { printf("%c", str[j]); j = j + dp[j]; } } else if (str[j] == 'i') { printf("%c", str[j]); j = j + dp[j]; } else if (str[j] == 'o') { if (dp[j] == 2) { printf("%c%c", str[j], str[j]); j = j + 2; } else { printf("%c", str[j]); j = j + dp[j]; } } else if (str[j] == 'u') { printf("%c", str[j]); j = j + dp[j]; } else if (str[j] == 'y') { printf("%c", str[j]); j = j + dp[j]; } else { printf("%c", str[j]); j = j + 1; } } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, i; string s, m; int main() { cin >> n >> s; m = s + "0123"; m[0] = s[0]; for (i = 1; i < n; i++) if (s[i] != 'e' && s[i] != 'o' && s[i] != 'i' && s[i] != 'y' && s[i] != 'u' && s[i] != 'a') { m[i] = s[i]; } else if (s[i] == s[i - 1]) m[i] = '*'; else { m[i] = s[i]; } m[n] = '3'; m[n + 1] = '3'; m[n + 2] = '3'; for (i = 0; i < n; i++) { if (m[i] != '*') { if ((m[i] == 'e' || m[i] == 'o') && m[i + 1] == '*' && m[i + 2] != '*') cout << m[i] << m[i]; else cout << m[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t; t = 1; while (t--) { long long n, i, c = 0; cin >> n; string s, s1 = "aeiouy"; cin >> s; for (i = 0; i < n; i++) { size_t found = s1.find(s[i]); if (found == string::npos) { if (c > 0) { if (c == 2 && (s[i - 1] == 'o' || s[i - 1] == 'e')) { cout << s[i - 1] << s[i - 1]; } else cout << s[i - 1]; c = 0; } cout << s[i]; } else { if (c == 0) { c++; continue; } if (s[i] == s[i - 1]) c++; else { if (c == 2 && (s[i - 1] == 'o' || s[i - 1] == 'e')) { cout << s[i - 1] << s[i - 1]; } else cout << s[i - 1]; c = 1; } } } if (c > 0) { if (c == 2 && (s[i - 1] == 'o' || s[i - 1] == 'e')) { cout << s[i - 1] << s[i - 1]; } else cout << s[i - 1]; c = 0; } } return 0; }
#include <bits/stdc++.h> char a[100005]; int main() { int n; scanf("%d", &n); scanf("%s", a); char flag = '\0'; int sum = 0; for (int i = 0; i < n; i++) { if (flag == a[i]) { sum++; } else { if ((flag == 'e' || flag == 'o') && sum == 2) ; else { for (int j = 0; j < sum - 1; j++) { a[i - j - 1] = '\0'; } } if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u' || a[i] == 'y') { flag = a[i]; sum = 1; } else flag = '\0', sum = 0; } } if ((flag == 'e' || flag == 'o') && sum == 2) ; else { for (int j = 0; j < sum - 1; j++) { a[n - 1 - j - 1] = '\0'; } } for (int i = 0; i < n; i++) if (a[i] != '\0') printf("%c", a[i]); printf("\n"); }
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k = 0, l, m, n; set<char> st; st.insert('a'); st.insert('e'); st.insert('i'); st.insert('o'); st.insert('u'); st.insert('y'); cin >> n; string s; cin >> s; string ans; for (i = 0; i < s.length();) { k = 0; if (st.find(s[i]) != st.end()) { char c = s[i]; if (s[i] == 'e' || s[i] == 'o') { while (s[i] == c && i < s.length()) { k++; i++; } ans += c; if (k == 2) ans += c; } else { while (s[i] == c && i < s.length()) { i++; } ans += c; } } else { ans += s[i]; i++; } } cout << ans; }