Submission #771128

#TimeUsernameProblemLanguageResultExecution timeMemory
771128pogsonCrossing (JOI21_crossing)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> struct ter { ter(const std::string& seqq) { seq = ""; for (int i = 0; i < seqq.size(); ++i) { char q = seqq[i]; int dig = 1; if (q == 'O') { dig = 0; } else if (q == 'I') { dig = 2; } seq += '0' + dig; } } ter operator *(int a) { ter temp = *this; for (int i = 0; i < seq.size(); ++i) { int dig = temp.seq[i] - '0'; dig *= a; dig %= 3; temp.seq[i] = '0' + dig; } return temp; } ter operator +(const ter& a) { ter temp = *this; for (int i = 0; i < seq.size(); ++i) { int dig = temp.seq[i] + a.seq[i] - 2 * '0'; dig %= 3; temp.seq[i] = '0' + dig; } return temp; } std::string seq; }; int main() { std::string a, b, c; std::set<std::string> all; int n; std::cin >> n; std::cin >> a >> b >> c; ter aa(a), bb(b), cc(c); all.insert({ aa.seq, bb.seq, cc.seq, ((aa + bb) * 2).seq, ((aa + cc) * 2).seq, ((cc + bb) * 2).seq }); all.insert({ (aa + bb + cc*2).seq, (aa + cc + bb * 2).seq, (cc + bb + aa * 2).seq }); //std::cout << "ALL POSSIBLE ANSWERES ARE" << std::endl; //for (const auto& s : all) { // std::cout << s << std::endl; //} //std::cout << "#####" << std::endl; int q; std::cin >> q; string s; std::cin >> s; std::cout << /*"S is obtainable? " << */ ((all.find(ter(s).seq) == all.end()) ? "NO" : "YES") << std::endl; while (q--) { int l, r; std::cin >> l >> r; char q; std::cin >> q; int dig = 1; if (q == 'O') { dig = 0; } else if (q == 'I'){ dig = 2; } for (int i = l - 1; i < r; ++i) { s[i] = dig + '0'; } //std::cout << "S is " << s << std::endl; std::cout << /*"S is obtainable? " << */ ((all.find(s) == all.end()) ? "NO" : "YES") << std::endl; } //ter a{ "1010" }; //ter b{ "2010" }; //std::cout << (a * 2).seq << std::endl; //std::cout << (a + b).seq << std::endl; return 0; }

Compilation message (stderr)

Main.cpp: In constructor 'ter::ter(const string&)':
Main.cpp:6:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |         for (int i = 0; i < seqq.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~
Main.cpp: In member function 'ter ter::operator*(int)':
Main.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int i = 0; i < seq.size(); ++i) {
      |                         ~~^~~~~~~~~~~~
Main.cpp: In member function 'ter ter::operator+(const ter&)':
Main.cpp:31:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int i = 0; i < seq.size(); ++i) {
      |                         ~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:60:5: error: 'string' was not declared in this scope
   60 |     string s;
      |     ^~~~~~
Main.cpp:60:5: note: suggested alternatives:
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
Main.cpp:61:17: error: 's' was not declared in this scope
   61 |     std::cin >> s;
      |                 ^