码迷,mamicode.com
首页 > 其他好文 > 详细

Train Problem I

时间:2018-07-07 18:00:51      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:ace   ++   else   bool   string   ++i   name   empty   using   

#include <iostream>
#include <string>
#include <stack>
using namespace std;
stack<char> s;
bool ans[100000];
int main()
{
int n;
string in,out;
while(cin>>n>>in>>out)
{
int id = 0,pos = 0;
while(!s.empty()) s.pop();
for(int i=0;i<n;i++)
{
s.push(in[i]);
ans[++id] = true;
while(!s.empty() && out[pos]==s.top())
{
ans[++id] = false;
s.pop();
pos++;
}
}
for(int i=pos;i<n;i++)
{
if(!s.empty() && out[i]==s.top())
{
ans[++id] = false;
s.pop();
}
else break;
}
if(id==2*n)
{
cout << "Yes." << endl;
for(int i=1;i<=id;i++)
if(ans[i]) cout << "in" << endl;
else cout << "out" << endl;
}
else cout <<"No." << endl;
cout << "FINISH" << endl;
}
return 0;
}

Train Problem I

标签:ace   ++   else   bool   string   ++i   name   empty   using   

原文地址:https://www.cnblogs.com/zmhdbk/p/9277267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!