博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1022 ( Train Problem I )
阅读量:4568 次
发布时间:2019-06-08

本文共 1111 字,大约阅读时间需要 3 分钟。

太囧了,刚开始我居然把

        while(!s.empty()) s.pop();

        while(!q.empty()) q.pop();

写成了

        if(!s.empty()) s.pop();

        if(!q.empty()) q.pop();

害我WA了十多次,浪费了不少时间。幸亏在论坛上发帖了,多谢这位兄弟发现了,再次感谢

Problem : 1022 ( Train Problem I ) Judge Status : Accepted RunId : 5628664 Language : C++ Author : ssun Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta #include<cstdio> #include<stack> #include<queue> #include<string> #include<iostream> using namespace std; int main() { stack<char> s; queue<string> q; char s1[110],s2[110]; int n; while(scanf("%d",&n)!= EOF) { //getchar(); while(!s.empty()) s.pop(); while(!q.empty()) q.pop(); scanf("%s%s",s1,s2); //cout<<strlen(s1)<<endl; //printf("%s\n%s",s1,s2); int k=0; int i=0; while(i<=n) { if(!s.empty()&&s.top()==s2[k]) { while(!s.empty()&&s.top()==s2[k]) { s.pop(); q.push("out"); k++; } if(k>=n) break; //i--; } else if(i==n) break; else { s.push(s1[i]); q.push("in"); i++; } } if(k>=n) { puts("Yes."); while(!q.empty()) { cout<<q.front()<<endl; q.pop(); } } else puts("No."); puts("FINISH"); } return 0; }

转载于:https://www.cnblogs.com/android-html5/archive/2012/03/24/2533912.html

你可能感兴趣的文章
numpy
查看>>
django | 连接mysql数据库
查看>>
导入sql时报日期类型错误
查看>>
更改arch的默认终端
查看>>
labelme2coco问题:TypeError: Object of type 'int64' is not JSON serializable
查看>>
JDBC连接MySQL数据库的方法和实例
查看>>
初学python之感悟
查看>>
(转)Secondary NameNode的作用
查看>>
Unable to read TLD "META-INF/c.tld" from JAR file
查看>>
React开发
查看>>
权限管理
查看>>
Python字符串操作
查看>>
连接池
查看>>
使用易语言COM对象取文件版本
查看>>
3、将uboot,kernel,rootfs下载到开发板上
查看>>
2.16.10.init进程详解1
查看>>
对redis深入理解
查看>>
centos7 install idea and x-windows
查看>>
Spring Boot + Spring Cloud 构建微服务系统(九):配置中心(Spring Cloud Config)
查看>>
【转】LINQ to SQL语句(1)之Where
查看>>