Language: C++

using namespace std;

using ULL = unsigned long long;
const ULL B = 100'000'007;

class SegmentTree {
 public:
  SegmentTree(int n) : size_(1), pow_(1, 1) {
    while(size_ < n) size_ <<= 1;
    node_.assign(size_ << 1, 0);
    lazy_.assign(size_ << 1, 0);
    awaiting_.assign(size_ << 1, false);
    while(pow_.size() <= size_) pow_.emplace_back(pow_.back() * B);
  }
  ULL find(int left, int right) {return find(left, right + 1, 1, 0, size_).value;}
  void update(int left, int right, ULL value) {update(left, right + 1, value, 1, 0, size_);}
 private:
  struct Node {ULL value; int length;};
  inline int left_child(int node) const {return node << 1;}
  inline int right_child(int node) const {return (node << 1) + 1;}
  inline ULL merge(ULL vl, ULL vr, int l) const {return vl * pow_.at(l) + vr;}
  inline Node merge(Node& l, Node& r) const {return {l.value * pow_.at(r.length) + r.value, l.length + r.length};}
  inline ULL hash(ULL v, int l) const {
    using Memo = pair<ULL, int>;
    static map<Memo, ULL> memo;
    auto m = Memo(v, l);
    if(memo.count(m)) return memo.at(m);
    ULL res = v;
    for(auto i = 1; i < l; ++i) res = res * B + v;
    memo.insert(make_pair(m, res));
    return res;
  }
  inline void propagate(int k, int l, int r) {
    if(awaiting_.at(k)) {
      if(k < size_) lazy_.at(left_child(k)) = lazy_.at(right_child(k)) = lazy_.at(k);
      if(k < size_) awaiting_.at(left_child(k)) = awaiting_.at(right_child(k)) = true;
      node_.at(k) = hash(lazy_.at(k), r - l);
      lazy_.at(k) = 0;
      awaiting_.at(k) = false;
    }
  }
  Node find(int a, int b, int k, int l, int r) {
    propagate(k, l, r);
    if(b <= l || r <= a) return {0, 0};
    if(a <= l && r <= b) return {node_.at(k) , r - l};
    auto vl = find(a, b, left_child(k), l, (l + r) / 2);
    auto vr = find(a, b, right_child(k), (l + r) / 2, r);
    return merge(vl, vr);
  }
  ULL update(int a, int b, ULL value, int k, int l, int r) {
    propagate(k, l, r);
    if(b <= l || r <= a) return node_.at(k);
    if(a <= l && r <= b) {lazy_.at(k) = value; awaiting_.at(k) = true; propagate(k, l, r); return node_.at(k);}
    auto vl = update(a, b, value, left_child(k), l, (l + r) / 2);
    auto vr = update(a, b, value, right_child(k), (l + r) / 2, r);
    return node_.at(k) = merge(vl, vr, (r - l) / 2);
  }
  int size_;
  vector<ULL> node_;
  vector<ULL> lazy_;
  vector<bool> awaiting_;
  vector<ULL> pow_;
 public:
  void traverse() {traverse(1,0,size_);}
  void traverse(int k, int l, int r, int d=0) {
    propagate(k, l, r);
    if(k < size_) {
      traverse(right_child(k),(l+r)/2,r,d+1);
      for(auto i=0;i<d;++i)cout<<"    ";
      cout<<node_.at(k)<<endl;
      traverse(left_child(k),l,(l+r)/2,d+1);
    } else {
      for(auto i=0;i<d;++i)cout<<"    ";
      cout<<node_.at(k)<<endl;
    }
  }
};

string compare(auto& t, int a, int b, int c, int d) {
  if(t.find(a, b) == t.find(c, d)) return "e";
  int low = -1, high = min(b - a, d - c) + 1;
  while(low + 1 != high) {
    auto middle = (low + high) / 2;
    if(t.find(a, a + middle) == t.find(c, c + middle)) low = middle;
    else high = middle;
  }
  if(low == b - a) return "s";
  if(low == d - c) return "t";
  return t.find(a + high, a + high) < t.find(c + high, c + high) ? "s" : "t";
}

int main() {
  int N;
  string U;
  int Q;
  cin >> N >> U >> Q;

  SegmentTree segtree(N);
  for(auto i = 0; i < N; ++i) segtree.update(i, i, U[i]);
//   segtree.traverse();

  for(auto i = 0; i < Q; ++i) {
    string s;
    cin >> s;
    if(s == "set") {
      int x, y; char z;
      cin >> x >> y >> z;
      --x; --y;
      segtree.update(x, y, z);
    } else {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      --a; --b; --c; --d;
      cout << compare(segtree, a, b, c, d) << endl;
    }
  }
}

Compiler output:
a.cc:59:3: error: 'vector' does not name a type
   59 |   vector<ULL> node_;
      |   ^~~~~~
a.cc:60:3: error: 'vector' does not name a type
   60 |   vector<ULL> lazy_;
      |   ^~~~~~
a.cc:61:3: error: 'vector' does not name a type
   61 |   vector<bool> awaiting_;
      |   ^~~~~~
a.cc:62:3: error: 'vector' does not name a type
   62 |   vector<ULL> pow_;
      |   ^~~~~~
a.cc: In constructor 'SegmentTree::SegmentTree(int)':
a.cc:8:34: error: class 'SegmentTree' does not have any field named 'pow_'
    8 |   SegmentTree(int n) : size_(1), pow_(1, 1) {
      |                                  ^~~~
a.cc:10:5: error: 'node_' was not declared in this scope
   10 |     node_.assign(size_ << 1, 0);
      |     ^~~~~
a.cc:11:5: error: 'lazy_' was not declared in this scope
   11 |     lazy_.assign(size_ << 1, 0);
      |     ^~~~~
a.cc:12:5: error: 'awaiting_' was not declared in this scope
   12 |     awaiting_.assign(size_ << 1, false);
      |     ^~~~~~~~~
a.cc:13:11: error: 'pow_' was not declared in this scope
   13 |     while(pow_.size() <= size_) pow_.emplace_back(pow_.back() * B);
      |           ^~~~
a.cc: In member function 'ULL SegmentTree::merge(ULL, ULL, int) const':
a.cc:21:62: error: 'pow_' was not declared in this scope
   21 |   inline ULL merge(ULL vl, ULL vr, int l) const {return vl * pow_.at(l) + vr;}
      |                                                              ^~~~
a.cc: In member function 'SegmentTree::Node SegmentTree::merge(Node&, Node&) const':
a.cc:22:64: error: 'pow_' was not declared in this scope
   22 |   inline Node merge(Node& l, Node& r) const {return {l.value * pow_.at(r.length) + r.value, l.length + r.length};}
      |                                                                ^~~~
a.cc:22:112: error: could not convert '{<expression error>, (l.SegmentTree::Node::length + r.SegmentTree::Node::length)}' from '<brace-enclosed initializer list>' to 'SegmentTree::Node'
   22 |   inline Node merge(Node& l, Node& r) const {return {l.value * pow_.at(r.length) + r.value, l.length + r.length};}
      |                                                                                                                ^
      |                                                                                                                |
      |                                                                                                                <brace-enclosed initializer list>
a.cc: In member function 'ULL SegmentTree::hash(ULL, int) const':
a.cc:24:18: error: 'pair' does not name a type
   24 |     using Memo = pair<ULL, int>;
      |                  ^~~~
a.cc:25:12: error: 'map' does not name a type
   25 |     static map<Memo, ULL> memo;
      |            ^~~
a.cc:26:14: error: 'Memo' was not declared in this scope
   26 |     auto m = Memo(v, l);
      |              ^~~~
a.cc:27:8: error: 'memo' was not declared in this scope
   27 |     if(memo.count(m)) return memo.at(m);
      |        ^~~~
a.cc:30:5: error: 'memo' was not declared in this scope
   30 |     memo.insert(make_pair(m, res));
      |     ^~~~
a.cc:30:17: error: 'make_pair' was not declared in this scope
   30 |     memo.insert(make_pair(m, res));
      |                 ^~~~~~~~~
a.cc:1:1: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | using namespace std;
a.cc: In member function 'void SegmentTree::propagate(int, int, int)':
a.cc:34:8: error: 'awaiting_' was not declared in this scope
   34 |     if(awaiting_.at(k)) {
      |        ^~~~~~~~~
a.cc:35:21: error: 'lazy_' was not declared in this scope
   35 |       if(k < size_) lazy_.at(left_child(k)) = lazy_.at(right_child(k)) = lazy_.at(k);
      |                     ^~~~~
a.cc:37:7: error: 'node_' was not declared in this scope
   37 |       node_.at(k) = hash(lazy_.at(k), r - l);
      |       ^~~~~
a.cc:37:26: error: 'lazy_' was not declared in this scope
   37 |       node_.at(k) = hash(lazy_.at(k), r - l);
      |                          ^~~~~
a.cc: In member function 'SegmentTree::Node SegmentTree::find(int, int, int, int, int)':
a.cc:45:34: error: 'node_' was not declared in this scope
   45 |     if(a <= l && r <= b) return {node_.at(k) , r - l};
      |                                  ^~~~~
a.cc:45:53: error: could not convert '{<expression error>, (r - l)}' from '<brace-enclosed initializer list>' to 'SegmentTree::Node'
   45 |     if(a <= l && r <= b) return {node_.at(k) , r - l};
      |                                                     ^
      |                                                     |
      |                                                     <brace-enclosed initializer list>
a.cc: In member function 'ULL SegmentTree::update(int, int, ULL, int, int, int)':
a.cc:52:33: error: 'node_' was not declared in this scope
   52 |     if(b <= l || r <= a) return node_.at(k);
      |                                 ^~~~~
a.cc:53:27: error: 'lazy_' was not declared in this scope
   53 |     if(a <= l && r <= b) {lazy_.at(k) = value; awaiting_.at(k) = true; propagate(k, l, r); return node_.at(k);}
      |                           ^~~~~
a.cc:53:48: error: 'awaiting_' was not declared in this scope
   53 |     if(a <= l && r <= b) {lazy_.at(k) = value; awaiting_.at(k) = true; propagate(k, l, r); return node_.at(k);}
      |                                                ^~~~~~~~~
a.cc:53:99: error: 'node_' was not declared in this scope
   53 |     if(a <= l && r <= b) {lazy_.at(k) = value; awaiting_.at(k) = true; propagate(k, l, r); return node_.at(k);}
      |                                                                                                   ^~~~~
a.cc:56:12: error: 'node_' was not declared in this scope
   56 |     return node_.at(k) = merge(vl, vr, (r - l) / 2);
      |            ^~~~~
a.cc: In member function 'void SegmentTree::traverse(int, int, int, int)':
a.cc:69:28: error: 'cout' was not declared in this scope
   69 |       for(auto i=0;i<d;++i)cout<<"    ";
      |                            ^~~~
a.cc:1:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:70:7: error: 'cout' was not declared in this scope
   70 |       cout<<node_.at(k)<<endl;
      |       ^~~~
a.cc:70:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:70:13: error: 'node_' was not declared in this scope
   70 |       cout<<node_.at(k)<<endl;
      |             ^~~~~
a.cc:70:26: error: 'endl' was not declared in this scope
   70 |       cout<<node_.at(k)<<endl;
      |                          ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:73:28: error: 'cout' was not declared in this scope
   73 |       for(auto i=0;i<d;++i)cout<<"    ";
      |                            ^~~~
a.cc:73:28: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:74:7: error: 'cout' was not declared in this scope
   74 |       cout<<node_.at(k)<<endl;
      |       ^~~~
a.cc:74:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:74:13: error: 'node_' was not declared in this scope
   74 |       cout<<node_.at(k)<<endl;
      |             ^~~~~
a.cc:74:26: error: 'endl' was not declared in this scope
   74 |       cout<<node_.at(k)<<endl;
      |                          ^~~~
a.cc:74:26: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc: At global scope:
a.cc:79:1: error: 'string' does not name a type
   79 | string compare(auto& t, int a, int b, int c, int d) {
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:94:3: error: 'string' was not declared in this scope
   94 |   string U;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:96:3: error: 'cin' was not declared in this scope
   96 |   cin >> N >> U >> Q;
      |   ^~~
a.cc:96:3: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:96:15: error: 'U' was not declared in this scope
   96 |   cin >> N >> U >> Q;
      |               ^
a.cc:103:11: error: expected ';' before 's'
  103 |     string s;
      |           ^~
      |           ;
a.cc:104:12: error: 's' was not declared in this scope
  104 |     cin >> s;
      |            ^
a.cc:114:7: error: 'cout' was not declared in this scope
  114 |       cout << compare(segtree, a, b, c, d) << endl;
      |       ^~~~
a.cc:114:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:114:15: error: 'compare' was not declared in this scope
  114 |       cout << compare(segtree, a, b, c, d) << endl;
      |               ^~~~~~~
a.cc:114:47: error: 'endl' was not declared in this scope
  114 |       cout << compare(segtree, a, b, c, d) << endl;
      |                                               ^~~~
a.cc:114:47: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'