C. Colorful Grid
1.C. Ehab and Path-etic MEXs2.Increase Subarray Sums3.F. Alex's whims4.C. Torn Lucky Ticket5.E. Cells Arrangement6.俄罗斯方块7.B. Omkar and Heavenly Tree
8.C. Colorful Grid
9.C. Lexicographically Largest10.A. Bitwise Operation Wizard11.B. Neutral Tonality12.M. 渚千夏的串13.D. Nene and the Mex Operator14.C. Nezzar and Symmetric Array15.D. Buying Jewels16.G. A/B Matrix题解
1.最小距离是n+m-2
2.后退多少就要前进多少,所以合法距离一定是偶数
3.猜测并验证n+m,n+m+2,n+m+4是否可行
4.如果n+m,我可以在终点设一个弯
5.如果n+m+2,我可以在起点设一个弯
6.两个弯可以组成任意偶数
code
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
void solve()
{
char a[20][20],b[20][20];
for(int i=1;i<=n;i++)
{
for(int j=1;j<m;j++)
{
a[i][j]='B';
}
}
for(int i=1;i<n;i++)
{
for(int j=1;j<=m;j++)
{
b[i][j]='B';
}
}
if(k<n+m-2||(k-n-m)%2)
{
puts("no");
return;
}
puts("yes");
int op=0;
for(int i=1;i<m;i++)
{
if(!op) a[1][i]='R';
else a[1][i]='B';
op^=1;
}
a[2][1]='R';
if((n+m)%2)
{
a[n-1][m-1]='R';
a[n][m-1]='R';
}
else
{
a[n-1][m-1]='B';
a[n][m-1]='B';
}
for(int i=1;i<n;i++)
{
if(!op) b[i][m]='R';
else b[i][m]='B';
op^=1;
}
b[1][1]='B';
b[1][2]='B';
if((n+m)%2)
{
b[n-1][m-1]='B';
}
else
{
b[n-1][m-1]='R';
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<m;j++)
{
if(!a[i][j]) cout<<"R ";
else cout<<a[i][j]<<" ";
}
puts("");
}
for(int i=1;i<n;i++)
{
for(int j=1;j<=m;j++)
{
if(!b[i][j]) cout<<"R ";
else cout<<b[i][j]<<" ";
}
puts("");
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
cin>>n>>m>>k;
solve();
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!