# Daily Coding Challenge #23

This is a series of Daily Coding Challenge. Each day I show a few solutions written in C++. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.

``````/*
Codeforces Round #632 (Div. 2) - A. Little Artem
https://codeforces.com/contest/1333/problem/A
*/

#include <bits/stdc++.h>
using namespace std;
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
FAST_INP;
int t,m,n;
cin >> t;
while(t--){
cin >> m >> n;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
// paint the top left corner to white
if(i==0&j==0) cout << 'W';
// paint others to black
else cout << 'B';
// then it can have B=W+1 for any size
}
cout << "\n";
}
}
return 0;
}

``````

``````/*
Codeforces Round #632 (Div. 2) - B. Kind Anton
https://codeforces.com/contest/1333/problem/B
*/

#include <bits/stdc++.h>
using namespace std;
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve(){
// by observation, if a[i] is not same as b[i], we need either 1 or -1 to equalise a[i] and b[i]
int n;
cin >> n;
vector<int> a(n),b(n);
// if f1=true, we can add b[j] by 1 since a[j]=1 where i<j
// if f2=true, we can substract b[j] from 1 since a[j]=-1 where i<j
bool f1=false,f2=false;
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++) cin >> b[i];
for(int i=0;i<n;i++){
// if a[i] < b[i], we need 1 to equalise
// if f1=false, then we cannot equalise for this case
if(a[i]<b[i]&&!f1){
cout << "NO\n";
return;
}
// if a[i] > b[i], we need -1 to equalise
// if f2=false, then we cannot equalise for this case
if(a[i]>b[i]&&!f2){
cout << "NO\n";
return;
}

// found 1
if(a[i]==1) f1=true;
// found -1
if(a[i]==-1) f2=true;
}
cout << "YES\n";
}

int main()
{
FAST_INP;
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}

``````

The source code is available in corresponding repo below. Star and watch for timely updates!

## wingkwong / atcoder

Posted on by:

### Wing-Kam

Consultant by day. Developer by night. AWS certified. Exploring #CloudNative currently.