287A - IQ Test - CodeForces Solution


brute force implementation *1100

Please click on ads to support us..

Python Code:

f = 0
a = [0] * 4
for i in range(4):
    a[i] = list(input())
    for j in range(4):
         a[i][j] = 1 if  a[i][j] == "#" else -1
    if i != 0:
        for j in range(3):
            if a[i - 1][j] + a[i][j] + a[i - 1][j + 1] + a[i][j + 1] == 0:
                continue
            else:
                f = 1
                break
    if f == 1:
        break
if f == 0:
    print("NO")
else:
    print('YES')

C++ Code:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int long long int 
#define vi(v) vector<int>v;
#define vec(v,n) vector<int>v(n);
#define vii(v) vector<ll>v;
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,m,n) for(int i=m;i<n;i++)
#define UMAP(ump) unordered_map<int,int>ump; 
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define SORT(V) sort(v.begin(),v.end());
#define SORT_ARRAY(arr,n) sort(arr,arr+n);
void print_array(int*arr,int n){
for(int i=0;i<n;i++){
cout<<arr[i]<<" ";
}cout<<endl;
}
void print_vector(vector<int>v){
for(auto it : v){
cout<<it<<" ";
}cout<<endl;
}



void solve(){

    vector<vector<int>>v(4,vector<int>(4,0));
    rep(i,0,4){
        rep(j,0,4){
            char c;
            cin>>c;
            if(c=='#'){
                v[i][j]=0;
                
            }
            else{
                v[i][j]=1;
            }
        }
    }


    rep(i,0,3){
        rep(j,0,3){
            int sum=v[i][j]+v[i][j+1]+v[i+1][j]+v[i+1][j+1];
            if(sum==1 || sum==3 || sum==0 || sum==4){
                cout<<"YES"<<endl;
                return;
            }

        }
    }

    cout<<"NO"<<endl;
    
    
    
}
int32_t main(){
fast
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}


Comments

Submit
0 Comments
More Questions

349A - Cinema Line
47A - Triangular numbers
1516B - AGAGA XOOORRR
1515A - Phoenix and Gold
1515B - Phoenix and Puzzle
155A - I_love_username
49A - Sleuth
1541A - Pretty Permutations
1632C - Strange Test
673A - Bear and Game
276A - Lunch Rush
1205A - Almost Equal
1020B - Badge
1353A - Most Unstable Array
770A - New Password
1646B - Quality vs Quantity
80A - Panoramix's Prediction
1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera