专栏文章
题解:P14603 [NWRRC 2025] Defense Distance
P14603题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mimxwrbv
- 此快照首次捕获于
- 2025/12/01 17:21 3 个月前
- 此快照最后确认于
- 2025/12/01 17:21 3 个月前
分析
神秘构造题。
设 、、 按升序排列,则:
- ,则无解。
- 否则,设 为一个字母 , 为 个 。则 长度为 。它的最后 个字符为 ,其他为 。
代码
CPP#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,at,bt,ct;
string s,t,u;
cin>>a>>b>>c;
at=a;
bt=b;
ct=c;
if(at>bt) swap(at,bt);
if(at>ct) swap(at,ct);
if(bt>ct) swap(bt,ct);
if(at+bt<ct)
{
cout<<"No";
return 0;
}
u='a';
s='a';
for(int i=1;i<=ct+1;i++) t+='a';
for(int i=1;i<=ct-bt;i++) u+='a';
for(int i=1;i<=at-ct+bt;i++) u+='b';
cout<<"Yes"<<endl;
if(c>=a&&a>=b) cout<<u<<endl<<t<<endl<<s;
else if(a>=b&&b>=c) cout<<t<<endl<<s<<endl<<u;
else if(b>=c&&c>=a) cout<<s<<endl<<u<<endl<<t;
else if(a>=c&&c>=b) cout<<s<<endl<<t<<endl<<u;
else if(b>=a&&a>=c) cout<<t<<endl<<u<<endl<<s;
else cout<<u<<endl<<s<<endl<<t;
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...