448B

Problem Link

 

View Code
#include<bits/stdc++.h>
using namespace std;
#define all(s) sort(s.begin(),s.end())
string s,t;
bool ar()
{all(s);all(t);
return s==t;
}

bool autom()
{
int c=0,sz=0;
int l=s.size();
for(int i=0;i<l;i++)
{
if(s[i]==t[c])
c++,sz++;
}

return sz==t.size()?1:0;

}
bool bt()
{
all(s);
all(t);
int c=0,sz=0;
int l=s.size();
for(int i=0;i<l;i++) { if(s[i]==t[c]) c++,sz++; } return sz==t.size()?1:0; } int main() { cin>>s>>t;
if(autom())
cout<<"automaton"<<endl;
else if(ar())
cout<<"array"<<endl;
else if(bt())
cout<<"both"<<endl;
else
cout<<"need tree"<<endl;

}

 

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s