社区
数据结构与算法
帖子详情
求 problem 1004 代码
Summy1208
2005-07-05 08:06:57
http://acm.zju.edu.cn/show_problem.php?pid=1004
...全文
112
2
打赏
收藏
求 problem 1004 代码
http://acm.zju.edu.cn/show_problem.php?pid=1004
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
mmmcd
2005-07-06
打赏
举报
回复
#include <stdio.h>
#include <string.h>
char s1[100],s2[100],stk[100],ans[200];
int l1,l2;
void output(int n)
{
int i;
for(i=0;i+1<n;i++)
{
printf("%c ",ans[i]);
}
printf("%c\n",ans[i]);
}
void go(int in,int out,int p,int top)
{
if(top<0)return;
if(in==l1 && out==l2)
{
output(p);
return;
}
if(in<l1)
{
stk[top]=s1[in];
ans[p]='i';
go(in+1,out,p+1,top+1);
}
if(top>0 && out<l2 && stk[top-1]==s2[out])
{
ans[p]='o';
go(in,out+1,p+1,top-1);
stk[top-1]=s2[out];
}
}
int main()
{
while(scanf("%s%s",s1,s2)==2)
{
l1=strlen(s1);
l2=strlen(s2);
printf("[\n");
if(l1==l2)go(0,0,0,0);
printf("]\n");
}
return 0;
}
Summy1208
2005-07-05
打赏
举报
回复
#include <iostream>
using namespace std;
char Src[500];
char Des[500];
char Stack[500];
char Result[1000];
int Len;
void Resolve(int nTop, int nSrc, int nDes, int nResult)
{
if (Stack[nTop] == Des[nDes])
{
Result[nResult++] = 'o';
nTop--;
++nDes;
if (nTop == 0 && nDes == Len)
{
cout<<Result<<'\n';
return;
}
else
Resolve(nTop, nSrc, nDes, nResult);
}
else
{
while (Stack[nTop] != Des[nDes])
{
Stack[++nTop] = Src[nSrc++];
Result[nResult++] = 'i';
}
Resolve(nTop, nSrc, nDes, nResult);
}
}
int main()
{
while(cin>>Src>>Des)
{
Len = strlen(Src);
cout<<"[\n";
if (Len == strlen(Des))
Resolve(0,0,0,0);
cout<<"]\n";
}
return 0;
}
小弟只能得到一个解 不知怎样回朔?
HDOJ 1000A + B
Problem
最短
代码
探索
这道题估计是HDOJ里最简单的了,不亦要挑战的是怎样用最短的
代码
AC它。 看了下HDOJ支持的编程语言,有C、C++、Java、Pascal和C#,对比了下,在这个场景C语言应该是最短的了。 那么,为了方便测试,直接用在线的...
A+B
problem
(各种
代码
大合集)
来就来个齐全的·· 为了防止题目变量值过大 所以拒绝int,选择long long(C或C++) ············...C语言
代码
#include <stdio.h> int main() { long long a,b; scanf("%d%d",&a,&b);
A+B
Problem
C语言
A+B
Problem
C语言
idea中控制台的
Problem
窗口,
代码
的实时编译错误提醒功能开启
idea中控制台的
Problem
窗口,
代码
的实时编译错误提醒功能开启 1.file—Settings—搜索compiler—将build project automatically点击之后应用该工程就会实时编译,提示错误 2.idea扫描dao层的时候报错,但是...
word安装Aurora写伪
代码
---
problem
running latex
由于需要在word中写伪
代码
,了解到可以使用Aurora插件实现! 虽然网上关于下载安装Aurora的文档和经验不少,但折腾了一天才能正常使用 安装资料和流程,可参考详情 关键步骤和常见问题 1.首先,想要在word中使用...
数据结构与算法
33,028
社区成员
35,337
社区内容
发帖
与我相关
我的任务
数据结构与算法
数据结构与算法相关内容讨论专区
复制链接
扫一扫
分享
社区描述
数据结构与算法相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章