fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define EPS (1e-9)
  5. #define ll long long int
  6. #define ull unsigned long long
  7. #define pb push_back
  8. #define mp make_pair
  9. #define pi (acos(-1.0))
  10. #define endl "\n"
  11. #define all(v) v.begin(),v.end()
  12. #define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
  13. #define precise(n) cout << fixed << setprecision(n)
  14. #define show(a) cout << (#a) << " is " << (a) << endl;
  15. #define pcase cout<<"Case "<<++cs<<": "
  16. #define FAST ios_base::sync_with_stdio(0); cin.tie(0);
  17. const int mod=1e9+7;
  18. ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
  19. ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  20. ull binpow(ll base, ll exp){ll res = 1;while(1){ if(exp&1) res*=base;exp>>=1;if(!exp)break;base*=base;}return res;}
  21. map<string,int>dictionary;
  22.  
  23. string ans;
  24. void init()
  25. {
  26. dictionary["CAT"]=1;
  27. dictionary["CUT"]=1;
  28. dictionary["TEE"]=1;
  29. dictionary["TOE"]=1;
  30. dictionary["EAT"]=1;
  31. dictionary["GET"]=1;
  32. dictionary["THE"]=1;
  33.  
  34. }
  35. int dp(char a,char b,char c)
  36. {
  37. string z;
  38. z.pb(a);
  39. z.pb(b);
  40. z.pb(c);
  41. if(dictionary[z]==1)
  42. {
  43. ans=z;
  44. return 1;
  45. }
  46. if(b=='Z')
  47. {
  48. return 0;
  49. }
  50.  
  51. return dp(a,b+1,c);
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59. int main()
  60. {
  61. int i,j,k,n;
  62. init();
  63. string s,s2;
  64. cin>> s >> s2;
  65. if(dictionary[s]!=1){
  66. if(dp(s[0],'A',s[2]))
  67. s= ans;
  68. else s="NOT AVAILABLE";
  69. }
  70.  
  71. if(dictionary[s2]!=1){
  72. if(dp(s2[0],'A',s2[2]))
  73. s2=ans;
  74. else s="NOT AVAILABLE";
  75. }
  76.  
  77. cout << s << endl << s2 << endl;
  78.  
  79. }
  80.  
Success #stdin #stdout 0s 4444KB
stdin
THE
CHT
stdout
THE
CAT