Solution to the problem 'A' from 'Hello 2022' Contest (Codeforces)
Here's my solution to problem A from the contest 'Hello 2022' of Codeforces.
Question Link: https://codeforces.com/contest/1621/problem/A
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--){
int n,k,m=0;
cin>>n>>k;
if(n%2==0){
if(k<=n/2){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(k>0 && i==2*m+1&&j==2*m+1){
cout<<'R';
k--;
m++;
}
else cout<<'.';
}
cout<<'\n';
}
}
else cout<<-1<<'\n';
}
else{
if(k<=(n/2)+1){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(k>0 && i==2*m+1&&j==2*m+1){
cout<<'R';
k--;
m++;
}
else cout<<'.';
}
cout<<'\n';
}
}
else cout<<-1<<'\n';
}
}
return 0;
}
Comments
Post a Comment