/** * author: oliverx3 * created: 16.05.2021 15:51:48 **/ #include #if __has_include() #include #endif #pragma region header #pragma region alias using lint = long long; using ll = long long; using P = std::pair; template using prique = std::priority_queue,std::greater>; #pragma endregion #pragma region macros #define rep(i, n) for(int i = 0;i<(int)(n);i++) #define REP(i, m, n) for(int i = (m);i<(int)(n);i++) #define drep(i, n) for(int i = (n)-1;i>=0;i--) #define DREP(i, m, n) for(int i = (m)-1;i>=(int)(n);i--) #define all(v) (v).begin(),(v).end() #define reall(v) (v).rbegin(),(v).rend() template bool chmax(T& a,const U b) { if(a < b) { a = b; return true; } return false; } template bool chmin(T& a,const U b) { if(a>b) { a = b; return true; } return false; } bool is_flag(const int &bit, const int &k) { return (bit >> k)&1; } #pragma endregion #pragma region constant constexpr int inf = 1<<30; constexpr long long INF = 1LL << 61; constexpr long double eps = 1e-10; constexpr long double pi = 3.141592653589793238; constexpr int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; constexpr int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1, 0}; constexpr long long mod = 1e9+7; constexpr long long MOD = 998244353; #pragma endregion #pragma region inout template std::ostream& operator<<(std::ostream& stream, const std::vector& v) { for(int i = 0; i < (int)(v.size()); i++) { stream << v[i]; if(i != (int)(v.size()) - 1) stream << ' '; } return stream; } template inline void print(const Itr& begin, const Itr& end, bool endline = true, const char* BEGIN = "{", const char* mid = ", ", const char* END = "}") { if(begin == end) return; std::cout << BEGIN << *begin; for(Itr itr = begin+1; itr < end; itr++) std::cout << mid << *itr; std::cout << END; if(endline) std::endl(std::cout); return; } template std::istream& operator>>(std::istream& stream, std::vector& v) { for(T& p:v) stream >> p; return stream; } template inline void input(Itr begin, Itr end) { for(Itr& itr = begin; itr < end; itr++) std::cin >> *itr; return; } template std::ostream& operator<<(std::ostream& stream, const std::pair& pair) { return stream << pair.first << ' ' << pair.second; } template inline void print(const std::pair& pair,const bool endline = true, const char* begin = "(", const char* mid = ", ", const char* end = ")") { std::cout << begin << pair.first << mid << pair.second << end; if(endline) std::endl(std::cout); else std::cout << ' '; return; } template std::istream& operator>>(std::istream& stream, std::pair& pair) { return stream >> pair.first >> pair.second; } template inline void input(std::pair& pair, const bool first = true, const bool second = true) { if(first) std::cin >> pair.first; if(second) std::cin >> pair.second; } #pragma endregion #pragma region DEBUG #ifdef _DEBUG template inline void _debug_view(const T& x) noexcept { std::cout << x; return; } template inline void _debug_view(const std::pair& p) noexcept { std::cout << "("; _debug_view(p.first); std::cout << ", "; _debug_view(p.second); std::cout << ")"; return; } template inline void _debug_view(const std::vector& v) noexcept { std::cout << "{"; for(int i = 0;i inline void _debug_view(const std::map& mp) noexcept { std::cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) { _debug_view(*itr); if(std::next(itr) != mp.end()) std::cout << ", "; } std::cout << "}"; return; } template inline void _debug_view(const std::set& st) noexcept { std::cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) { _debug_view(*itr); if(std::next(itr) != st.end()) std::cout << ", "; } std::cout << "}"; return; } #define overload5(_1,_2,_3,_4,_5,name,...) name #define _debug1(a) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::endl(std::cout);\ }while(0);\ } #define _debug2(a,b) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::endl(std::cout);\ }while(0);\ } #define _debug3(a,b,c) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::endl(std::cout);\ }while(0);\ } #define _debug4(a,b,c,d) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::cout << ", " << #d << ": ";\ _debug_view(d);\ std::endl(std::cout);\ }while(0);\ } #define _debug5(a,b,c,d,e) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::cout << ", " << #d << ": ";\ _debug_view(d);\ std::cout << ", " << #e << ": ";\ _debug_view(e);\ std::endl(std::cout);\ }while(0);\ } #define debug(...) overload5(__VA_ARGS__,_debug5,_debug4,_debug3,_debug2,_debug1,)(__VA_ARGS__) #else #define debug(...) #endif #pragma endregion #pragma endregion struct angle { P a, b, c; }; bool operator<(const angle& a, const angle& b) { if(a.a!=b.a) return a.a> s; std::set st; P A{0, 0}, B{1, 0}, C{0, 1}; st.insert(f(A,B,C)); for(const auto &c:s) { if(c == 'a') { P &a = A, b = std::min(B, C), c = std::max(B, C); debug(a, b, c); if(a.first==b.first&&a.second==c.second) { a.first++, a.second++; } else if(a.first==b.first&&a.second==b.second+1&&a.second==c.second+1) { a.first++, a.second-=2; } else if(a.first==b.first+1&&a.first==c.first+1&&a.second==b.second) { a.first-=2, a.second++; } else if(a.first==b.first-1&&a.first==c.first-1&&a.second==c.second) { a.first+=2, a.second-=1; } else if(a.first==c.first&&a.second==b.second) { a.first--, a.second--; } else { a.first--, a.second+=2; } } else if(c == 'b') { std::swap(A, B); P &a = A, b = std::min(B, C), c = std::max(B, C); if(a.first==b.first&&a.second==c.second) { a.first++, a.second++; } else if(a.first==b.first&&a.second==b.second+1&&a.second==c.second+1) { a.first++, a.second-=2; } else if(a.first==b.first+1&&a.first==c.first+1&&a.second==b.second) { a.first-=2, a.second++; } else if(a.first==b.first-1&&a.first==c.first-1&&a.second==c.second) { a.first+=2, a.second-=1; } else if(a.first==c.first&&a.second==b.second) { a.first--, a.second--; } else { a.first--, a.second+=2; } std::swap(A, B); } else { std::swap(A, C); P &a = A, b = std::min(B, C), c = std::max(B, C); if(a.first==b.first&&a.second==c.second) { a.first++, a.second++; } else if(a.first==b.first&&a.second==b.second+1&&a.second==c.second+1) { a.first++, a.second-=2; } else if(a.first==b.first+1&&a.first==c.first+1&&a.second==b.second) { a.first-=2, a.second++; } else if(a.first==b.first-1&&a.first==c.first-1&&a.second==c.second) { a.first+=2, a.second-=1; } else if(a.first==c.first&&a.second==b.second) { a.first--, a.second--; } else { a.first--, a.second+=2; } std::swap(A, C); } st.insert(f(A, B, C)); debug(A, B, C); } // for(const auto &p:st) debug(p.a, p.b, p.c); std::cout << st.size() << std::endl; return 0; }