st = str(input())
en = str(input())
dst = [0]*26
den = [0]*26
for i in range(len(st)):
dst[ord(st[i])-97] += 1
for i in range(len(en)):
den[ord(en[i])-97] += 1
if len(en) > len(st):
print("need tree")
elif len(en) == len(st):
if dst != den:
print("need tree")
else:
print("array")
else:
p1,p2 = 0,0
flag = False
while p2 < len(st):
if st[p2] == en[p1]:
if p1 == len(en)-1:
flag = True
break
p1 += 1
p2 += 1
if flag:
print("automaton")
else:
flag = True
for i in range(26):
if den[i] > dst[i]:
print("need tree")
flag = False
break
if flag:
print("both")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
bool is_only_automaton(const string &s, const string &t) {
size_t j = -1;
for (int i = 0; i < t.size(); i++) {
j = s.find_first_of(t[i], j+1);
if (j == string::npos) {
return false;
}
}
return true;
}
int main() {
string s;
string t;
cin>>s;
cin>>t;
string ret = "need tree";
assert(s != t);
if (s.size() == t.size()) {
sort(s.begin(), s.end());
sort(t.begin(), t.end());
if (s == t) {
ret = std::move("array");
}
}
else if (is_only_automaton(s, t)) {
ret = std::move("automaton");
}
else {
sort(s.begin(), s.end());
sort(t.begin(), t.end());
if (is_only_automaton(s, t)) {
ret = std::move("both");
}
}
cout<<ret<<endl;
return 0;
}
1630C - Paint the Middle | 1630D - Flipping Range |
1328A - Divisibility Problem | 339A - Helpful Maths |
4A - Watermelon | 476A - Dreamoon and Stairs |
1409A - Yet Another Two Integers Problem | 977A - Wrong Subtraction |
263A - Beautiful Matrix | 180C - Letter |
151A - Soft Drinking | 1352A - Sum of Round Numbers |
281A - Word Capitalization | 1646A - Square Counting |
266A - Stones on the Table | 61A - Ultra-Fast Mathematician |
148A - Insomnia cure | 1650A - Deletions of Two Adjacent Letters |
1512A - Spy Detected | 282A - Bit++ |
69A - Young Physicist | 1651A - Playoff |
734A - Anton and Danik | 1300B - Assigning to Classes |
1647A - Madoka and Math Dad | 710A - King Moves |
1131A - Sea Battle | 118A - String Task |
236A - Boy or Girl | 271A - Beautiful Year |