#include #include #include #include using namespace std; using namespace __gnu_pbds; #define rep(i,n) for(int i = 0;i<(n);i++) #define per(i,n) for(int i = (n-1);i>=0;i--) #define nfor(i,b,e) for(int i = b;i<(e);i++) #define Sort(a) sort((a).begin(), (a).end()) #define Rev(a) reverse((a).begin(), (a).end()) #define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__) #define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__)//reverseしてからall #define endl '\n' #define YesNo(bool) if(bool){cout<<"Yes"< // Tu は最大値のある符号無し整数型 (型チェックに必要な static_assert などは省略) template static inline constexpr bool is_multiplication_safe(Tu a, Tu b){ return !a || b <= std::numeric_limits::max() / a; } template static inline constexpr bool is_addition_safe(Tu a, Tu b){ if(a*b <= 0) return true; else if(a<0 && b<0) return b >= std::numeric_limits::max() - a; else if(a>0 && b>0) return b <= std::numeric_limits::max() - a; } //O(NlogN)の計算量が必要 template double median(std::vector numbers) { std::sort(numbers.begin(), numbers.end()); size_t size = numbers.size(); if (size % 2 == 0) return (numbers[size / 2 - 1] + numbers[size / 2]) / 2.0; else return numbers[size / 2]; } #define debug(var) DEBUG(#var, var) #ifdef _DEBUG // 基本データ型用のデバッグ関数 template void DEBUG(const char* varName, const T& value) { std::cout << varName << ":" << value << endl; } // std::string用のデバッグ関数 void DEBUG(const char* varName, const std::string& value) { std::cout << varName << ":"<< value << endl; } // std::array用のデバッグ関数 template void DEBUG(const char* varName, const std::array& arr) { std::cout << varName << ":"; for (const auto& el : arr) { std::cout << el << " "; } std::cout << endl; } // std::vector用のデバッグ関数 template void DEBUG(const char* varName, const std::vector& vec) { std::cout << varName << ":"; for (const auto& el : vec) { std::cout << el << " "; } std::cout << endl; } // std::stack用のデバッグ関数 template void DEBUG(const char* varName, const std::stack stk) { std::cout << varName << ":"; std::stack copy = stk; // コピーして内容を出力 std::vector res; while (!copy.empty()) { res.push_back(copy.top()); copy.pop(); } Rev(res); debug(res); } // std::set用のデバッグ関数 template void DEBUG(const char* varName, const std::set& s) { std::cout << varName << ":"; for (const auto& el : s) { std::cout << el << " "; } std::cout << endl; } // 二次元配列用のデバッグ関数 template void DEBUG(const char* varName, const std::vector>& matrix) { std::cout << varName << ":"<< endl; for (const auto& row : matrix) { for (const auto& el : row) { std::cout << el << " "; } std::cout << endl; } } #else #define debug(var) #endif //を<使いたい型>に書き変える //*orderd_set.find_by_order(i)で値を取得する。 using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; using ll = long long; using ull = unsigned long long; using Lf = long double; using vi = vector; using vc = vector; using vvi = vector>; using vvc = vector>; using vvvi = vector>>; using vll = vector; using vvll = vector>; using Pii = pair; #define make(x,y) make_pair(x,y) //vector to string string to_string(vector a){ int n = a.size(); string res = ""; rep(i,n) res += char(a[i]+'0'); return res; } long double euclid_dist(long double xi,long double yi,long double xj,long double yj){ return sqrt((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj)); } ull factorial(int n){ if(n==0||n==1) return 1ULL; else return factorial(n-1)*n; } template struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; } ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } }; using mint = ModInt<1000000007>; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; stack> stk; int n = s.size(); stk.push(make_pair(s[n-1],1)); for(int i = n-2;i>=0;i--){ if(s[i] == '=' && stk.top().first==s[i]){ stk.top().second++; }else{ stk.push(make_pair(s[i],1)); } } stack> stk2; while(!stk.empty()){ char c = stk.top().first; int num = stk.top().second; stk.pop(); if(!stk2.empty() && stk2.top().first==c && c=='='){ stk2.top().second += num; continue; } if(stk2.size()>=2 && c == '>'){ auto pop1 = stk2.top(); if(pop1.first=='=') stk2.pop(); else{ stk2.push(make_pair(c,num)); continue; } auto pop2 = stk2.top(); if(pop2.first=='<') stk2.pop();//ここが1だった・・・ else{ stk2.push(pop1); stk2.push(make_pair(c,num)); continue; } }else{ stk2.push(make_pair(c,num)); } } ll ans = 0; vector dbg; while(!stk2.empty()){ dbg.push_back(stk2.top().first); ans += stk2.top().second; cout << ans << endl; stk2.pop(); } Rev(dbg); debug(dbg); cout <======>