Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp> // Common file
- #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
- #define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- using namespace std;
- using namespace __gnu_pbds;
- using ll = long long;
- template<typename key> using ordered_set = tree <key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
- char arr[8][8];
- bool checkRow(int r, int c) {
- for(int i = c + 1; i < 8; i++) {
- if(arr[r][i] == '*')
- return true;
- }
- return false;
- }
- bool checkCol(int r, int c) {
- for(int i = r + 1; i < 8; i++) {
- if(arr[i][c] == '*')
- return true;
- }
- return false;
- }
- bool checkDiag(int r, int c) {
- for(int i = r + 1, j = c + 1; i < 8 && j < 8; i++, j++) {
- if(arr[i][j] == '*') {
- return true;
- }
- }
- for(int i = r + 1, j = c - 1; i < 8 && j >= 0; i++, j--) {
- if(arr[i][j] == '*') {
- return true;
- }
- }
- for(int i = r - 1, j = c + 1; i >= 0 && j < 8; i--, j++) {
- if(arr[i][j] == '*') {
- return true;
- }
- }
- for(int i = r - 1, j = c - 1; i >= 0 && j >= 0; i--, j--) {
- if(arr[i][j] == '*') {
- return true;
- }
- }
- return false;
- }
- int main() {
- IO;
- for(int i = 0; i < 8; i++) {
- for(int j = 0; j < 8; j++)
- cin >> arr[i][j];
- }
- for(int i = 0; i < 8; i++) {
- for(int j = 0; j < 8; j++) {
- if(arr[i][j] == '*') {
- if(checkRow(i, j) || checkCol(i, j) || checkDiag(i, j)) {
- return cout << "invalid", 0;
- }
- }
- }
- }
- cout << "valid";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement