Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. typedef pair<int, int> pii;
  6. typedef pair<ll, ll> pll;
  7. typedef pair<int, ll> pil;
  8. typedef pair<ll, int> pli;
  9. typedef pair<double,double> pdd;
  10. #define SQ(i) ((i)*(i))
  11. #define MEM(a, b) memset(a, (b), sizeof(a))
  12. #define SZ(i) int(i.size())
  13. #define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
  14. #define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
  15. #define REP(i, j) FOR(i, 0, j, 1)
  16. #define REP1(i,j) FOR(i, 1, j+1, 1)
  17. #define RREP(i, j) RFOR(i, j, 0, 1)
  18. #define ALL(_a) _a.begin(),_a.end()
  19. #define mp make_pair
  20. #define pb push_back
  21. #define eb emplace_back
  22. #define X first
  23. #define Y second
  24. #ifdef jayinnn
  25. #define TIME(i) Timer i(#i)
  26. #define debug(...) do{\
  27.     fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
  28.     _do(__VA_ARGS__);\
  29. }while(0)
  30. template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
  31. template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
  32. template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
  33. template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
  34. {
  35.     _s<<"{";
  36.     for(It _it=_ita;_it!=_itb;_it++)
  37.     {
  38.         _s<<(_it==_ita?"":",")<<*_it;
  39.     }
  40.     _s<<"}";
  41.     return _s;
  42. }
  43. template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
  44. template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
  45. template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
  46. template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
  47. template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
  48. #define IOS()
  49. class Timer {
  50. private:
  51.     string scope_name;
  52.     chrono::high_resolution_clock::time_point start_time;
  53. public:
  54.     Timer (string name) : scope_name(name) {
  55.         start_time = chrono::high_resolution_clock::now();
  56.     }
  57.     ~Timer () {
  58.         auto stop_time = chrono::high_resolution_clock::now();
  59.         auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
  60.         double mlength = double(length) * 0.001;
  61.         debug(scope_name, mlength);
  62.     }
  63. };
  64. #else
  65. #define TIME(i)
  66. #define debug(...)
  67. #define pary(...)
  68. #define endl '\n'
  69. #define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
  70. #endif
  71.  
  72. const ll MOD = 1000000007;
  73. const ll INF = 0x3f3f3f3f3f3f3f3f;
  74. const int iNF = 0x3f3f3f3f;
  75. const ll MAXN = 100005;
  76.  
  77. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  78.  
  79. string ele[118] = {"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm","Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"};
  80. bool check(string s){
  81.     for(int i=0;i<118;i++) if(s == ele[i]) return true;
  82.  
  83.     return false;
  84. }
  85.  
  86. /********** Good Luck :) **********/
  87. int main () {
  88.     TIME(main);
  89.     IOS();
  90.  
  91.     string s;
  92.     int n = 118;
  93.     cin >> s;
  94.     int sz = s.size();
  95.     string tmp = "";
  96.     bool flag = false;
  97.     for(int i=0;i<n;i++) transform(ele[i].begin(), ele[i].end(), ele[i].begin(), ::toupper);
  98.    
  99.     for(int i=0;i <= pow(2, sz+1);i++){
  100.         flag = false;
  101.         int idx = 0;
  102.         int cnt = i;
  103.         debug(cnt);
  104.         while(idx < sz){
  105.             tmp = "";
  106.             if(cnt % 2 == 0){
  107.                 tmp += s[idx];
  108.                 tmp += s[idx+1];
  109.                 debug(tmp);
  110.                 if(!check(tmp)){
  111.                     flag = true;
  112.                     break;
  113.                 } else {
  114.                     idx += 2;
  115.                 }
  116.             } else {
  117.                 tmp += s[idx];
  118.                 if(!check(tmp)){
  119.                     flag = true;
  120.                     break;
  121.                 } else {
  122.                     idx += 1;
  123.                 }
  124.             }
  125.             cnt /= 2;
  126.         }
  127.         if(!flag){
  128.             break;
  129.         }
  130.     }
  131.  
  132.     if(!flag) cout << "YES" << endl;
  133.     else cout << "NO" << endl;
  134.     return 0;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement