Language: C++

#error "tsurai"

#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>

template <intmax_t X=9436884629, intmax_t MOD=1000000007>
class RollingHash {
  std::vector<intmax_t> hash_;
  intmax_t offset(size_t len) const {
    intmax_t res=1;
    for (intmax_t dbl=X%MOD; len; len>>=1) {
      if (len & 1)
        res = res*dbl % MOD;

      dbl = dbl*dbl % MOD;
    }

    return res;
  }

public:
  RollingHash(const std::string &s): hash_(s.length()+1) {
    for (size_t i=0; i<s.length(); ++i)
      hash_[i+1] = (hash_[i]*X+s[i]) % MOD;
  }

  intmax_t prefix(size_t i) const {
    // hash of prefix s[0..i-1] (inclusive)
    assert(0 < i);
    return hash_[i];
  }

  intmax_t substr(size_t i, size_t j) const {
    // hash of substring s[i..j-1] (inclusive)
    assert(i < j);
    intmax_t res=hash_[j];
    res = (res - offset(j-i)*hash_[i]) % MOD;
    if (res < 0) res += MOD;
    return res;
  }

  intmax_t hash() const {
    return hash_.back();
  }

  void debug() const {
    for (size_t i=0; i<hash_.size(); ++i)
      fprintf(stderr, "%jd%c", hash_[i], i+1<hash_.size()? ' ':'\n');
  }
};

struct DML {
  using Tags = std::vector<intmax_t>;
  std::string filename;
  std::vector<std::pair<Tags, std::string>> contents;
  DML(const std::string &filename, const std::string &file):
    filename(filename)
  {
    std::pair<Tags, std::string> opened;
    for (size_t i=0; i<file.size(); ++i) {
      if (file[i] == '<') {
        ++i;
        if (file[i] == '/') {
          while (file[i] != '>') ++i;
          contents.push_back(opened);
          opened.first.pop_back();
          opened.second = "";
        } else {
          std::string tag;
          while (file[i] != '>') tag += file[i++];
          if (tag == "br") {
            opened.second += '\n';
          } else {
            contents.emplace_back(opened);
            opened.first.emplace_back(RollingHash<>(tag).hash());
            opened.second = "";
          }
        }
        continue;
      }
      opened.second += file[i];
    }
  }
};

struct DS {
  using Selector = std::vector<intmax_t>;
  using Property = std::pair<Selector, bool>;
  std::map<intmax_t, std::vector<Property>> funcs;

  void add(const std::string &file) {
    for (size_t i=0; i<file.size(); ++i) {
      assert(isalpha(file[i]));
      std::string func;
      while (file[i] != '{') func += file[i++];

      assert(file[i] == '{');
      ++i;

      while (file[i] != '}') {
        while (file[i] != ';') {
          std::vector<std::vector<std::string>> sel;
          std::vector<bool> val;

          std::string id;
          while (isalpha(file[i])) {
            id += file[i++];
          }
          if (file[i] == '.') {
            sel.back().emplace_back(id);
            ++i;
          } else if (file[i] == '!') {
            val.emplace_back(false);
            i += 2;
          } else if (file[i] == '=') {
            val.emplace_back(true);
            ++i;
          } else {
            assert(false);
          }

          assert(sel.back().back() == "true" || sel.back().back() == "false");
          if (sel.back().back()[0] == 'f') {
            val.flip();
          }
          for (size_t i=0; i+1<sel.size(); ++i) {
            std::string id;
            for (size_t j=0; j+1<sel[i].size(); ++j) {
              id += '.';
              id += sel[i][j];
            }
            fprintf(stderr, "%s: %s\n", id.c_str(), val[i]? "true":"false");
          }
        }
      }
    }
  }
};

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<DML> dml;
  DS ds;
  std::map<std::string, size_t> ind;
  for (size_t i=0; i<N; ++i) {
    char buf[32], file[512];
    scanf("%s %s", buf, file);
    std::string filename=buf;
    if (filename.back() == 's') {
      ds.add(file);
    } else {
      dml.emplace_back(filename, file);
      ind[filename] = i+1;
    }
  }

  int M;
  scanf("%d", &M);
  for (int i=0; i<M; ++i) {
    size_t w, h;
    int s;
    char buf[32];
    scanf("%zu %zu %d %s", &w, &h, &s, buf);
    std::string startfile=buf;
    size_t cur=ind[startfile+".dml"];
    assert(cur > 0);

    for (int j=0; j<s; ++j) {
      size_t x, y;
      scanf("%zu %zu", &x, &y);

      
    }
  }
}



Compiler output:
a.cc:1:2: error: #error "tsurai"
    1 | #error "tsurai"
      |  ^~~~~
a.cc:27:26: error: 'string' in namespace 'std' does not name a type
   27 |   RollingHash(const std::string &s): hash_(s.length()+1) {
      |                          ^~~~~~
a.cc:10:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    9 | #include <map>
  +++ |+#include <string>
   10 | 
a.cc: In constructor 'RollingHash<X, MOD>::RollingHash(const int&)':
a.cc:27:46: error: request for member 'length' in 's', which is of non-class type 'const int'
   27 |   RollingHash(const std::string &s): hash_(s.length()+1) {
      |                                              ^~~~~~
a.cc:28:26: error: request for member 'length' in 's', which is of non-class type 'const int'
   28 |     for (size_t i=0; i<s.length(); ++i)
      |                          ^~~~~~
a.cc:29:33: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   29 |       hash_[i+1] = (hash_[i]*X+s[i]) % MOD;
      |                                 ^
a.cc: At global scope:
a.cc:59:8: error: 'string' in namespace 'std' does not name a type
   59 |   std::string filename;
      |        ^~~~~~
a.cc:59:3: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
   59 |   std::string filename;
      |   ^~~
a.cc:60:36: error: 'string' is not a member of 'std'
   60 |   std::vector<std::pair<Tags, std::string>> contents;
      |                                    ^~~~~~
a.cc:60:36: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:60:36: error: template argument 2 is invalid
a.cc:60:42: error: template argument 1 is invalid
   60 |   std::vector<std::pair<Tags, std::string>> contents;
      |                                          ^~
a.cc:60:42: error: template argument 2 is invalid
a.cc:61:18: error: 'string' in namespace 'std' does not name a type
   61 |   DML(const std::string &filename, const std::string &file):
      |                  ^~~~~~
a.cc:61:13: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
   61 |   DML(const std::string &filename, const std::string &file):
      |             ^~~
a.cc:61:47: error: 'string' in namespace 'std' does not name a type
   61 |   DML(const std::string &filename, const std::string &file):
      |                                               ^~~~~~
a.cc:61:42: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
   61 |   DML(const std::string &filename, const std::string &file):
      |                                          ^~~
a.cc: In constructor 'DML::DML(const int&, const int&)':
a.cc:62:5: error: class 'DML' does not have any field named 'filename'
   62 |     filename(filename)
      |     ^~~~~~~~
a.cc:64:26: error: 'string' is not a member of 'std'
   64 |     std::pair<Tags, std::string> opened;
      |                          ^~~~~~
a.cc:64:26: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:64:32: error: template argument 2 is invalid
   64 |     std::pair<Tags, std::string> opened;
      |                                ^
a.cc:65:29: error: request for member 'size' in 'file', which is of non-class type 'const int'
   65 |     for (size_t i=0; i<file.size(); ++i) {
      |                             ^~~~
a.cc:66:15: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   66 |       if (file[i] == '<') {
      |               ^
a.cc:68:17: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   68 |         if (file[i] == '/') {
      |                 ^
a.cc:69:22: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   69 |           while (file[i] != '>') ++i;
      |                      ^
a.cc:70:20: error: request for member 'push_back' in '((DML*)this)->DML::contents', which is of non-class type 'int'
   70 |           contents.push_back(opened);
      |                    ^~~~~~~~~
a.cc:71:18: error: request for member 'first' in 'opened', which is of non-class type 'int'
   71 |           opened.first.pop_back();
      |                  ^~~~~
a.cc:72:18: error: request for member 'second' in 'opened', which is of non-class type 'int'
   72 |           opened.second = "";
      |                  ^~~~~~
a.cc:74:16: error: 'string' is not a member of 'std'
   74 |           std::string tag;
      |                ^~~~~~
a.cc:74:16: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:75:22: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   75 |           while (file[i] != '>') tag += file[i++];
      |                      ^
a.cc:75:34: error: 'tag' was not declared in this scope
   75 |           while (file[i] != '>') tag += file[i++];
      |                                  ^~~
a.cc:75:45: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   75 |           while (file[i] != '>') tag += file[i++];
      |                                             ^
a.cc:76:15: error: 'tag' was not declared in this scope
   76 |           if (tag == "br") {
      |               ^~~
a.cc:77:20: error: request for member 'second' in 'opened', which is of non-class type 'int'
   77 |             opened.second += '\n';
      |                    ^~~~~~
a.cc:79:22: error: request for member 'emplace_back' in '((DML*)this)->DML::contents', which is of non-class type 'int'
   79 |             contents.emplace_back(opened);
      |                      ^~~~~~~~~~~~
a.cc:80:20: error: request for member 'first' in 'opened', which is of non-class type 'int'
   80 |             opened.first.emplace_back(RollingHash<>(tag).hash());
      |                    ^~~~~
a.cc:81:20: error: request for member 'second' in 'opened', which is of non-class type 'int'
   81 |             opened.second = "";
      |                    ^~~~~~
a.cc:86:14: error: request for member 'second' in 'opened', which is of non-class type 'int'
   86 |       opened.second += file[i];
      |              ^~~~~~
a.cc:86:28: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   86 |       opened.second += file[i];
      |                            ^
a.cc: At global scope:
a.cc:96:23: error: 'string' in namespace 'std' does not name a type
   96 |   void add(const std::string &file) {
      |                       ^~~~~~
a.cc:96:18: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
   96 |   void add(const std::string &file) {
      |                  ^~~
a.cc: In member function 'void DS::add(const int&)':
a.cc:97:29: error: request for member 'size' in 'file', which is of non-class type 'const int'
   97 |     for (size_t i=0; i<file.size(); ++i) {
      |                             ^~~~
In file included from /usr/include/c++/14/cassert:44,
                 from a.cc:6:
a.cc:98:26: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
   98 |       assert(isalpha(file[i]));
      |                          ^
a.cc:99:12: error: 'string' is not a member of 'std'
   99 |       std::string func;
      |            ^~~~~~
a.cc:99:12: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:100:18: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  100 |       while (file[i] != '{') func += file[i++];
      |                  ^
a.cc:100:30: error: 'func' was not declared in this scope; did you mean 'funcs'?
  100 |       while (file[i] != '{') func += file[i++];
      |                              ^~~~
      |                              funcs
a.cc:100:42: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  100 |       while (file[i] != '{') func += file[i++];
      |                                          ^
a.cc:102:18: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  102 |       assert(file[i] == '{');
      |                  ^
a.cc:105:18: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  105 |       while (file[i] != '}') {
      |                  ^
a.cc:106:20: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  106 |         while (file[i] != ';') {
      |                    ^
a.cc:107:40: error: 'string' is not a member of 'std'
  107 |           std::vector<std::vector<std::string>> sel;
      |                                        ^~~~~~
a.cc:107:40: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:107:40: error: template argument 1 is invalid
a.cc:107:40: error: template argument 2 is invalid
a.cc:107:46: error: template argument 1 is invalid
  107 |           std::vector<std::vector<std::string>> sel;
      |                                              ^~
a.cc:107:46: error: template argument 2 is invalid
a.cc:110:16: error: 'string' is not a member of 'std'
  110 |           std::string id;
      |                ^~~~~~
a.cc:110:16: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:111:30: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  111 |           while (isalpha(file[i])) {
      |                              ^
a.cc:112:13: error: 'id' was not declared in this scope; did you mean 'i'?
  112 |             id += file[i++];
      |             ^~
      |             i
a.cc:112:23: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  112 |             id += file[i++];
      |                       ^
a.cc:114:19: error: invalid types 'const int[size_t {aka long unsigned int}]' for array subscript
  114 |           if (file[i] ==