結果
問題 |
No.2539 スライムゲーム
|
ユーザー |
![]() |
提出日時 | 2023-11-10 23:19:38 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,781 bytes |
コンパイル時間 | 928 ms |
コンパイル使用メモリ | 92,088 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 02:18:45 |
合計ジャッジ時間 | 2,069 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 |
ソースコード
#include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; long long st[101010]; // Single line reading functions for multi-case & NO final case notification inputs // Verified: https://codeforces.com/gym/100162/problem/G std::vector<int> read_ints() { std::string s; std::getline(std::cin, s); if (s.empty()) return {}; std::stringstream ss(s); std::vector<int> ret; while (!ss.eof()) { int t; ss >> t; ret.push_back(t); } return ret; } std::string read_str() { std::string s; std::getline(std::cin, s); return s; } int main() { cin.tie(nullptr)->sync_with_stdio(false); string s = read_str(); // vector<long long> st{0}; // bool is_inf = false; constexpr long long thres = 1000000000000000000LL; int rr = 0; for (int i = (int)s.size() - 1; i >= 0; --i) { if (s.at(i) == '(') { if (rr == 0) { st[rr] += 1; break; } const auto v = st[rr--]; // st.pop_back(); if (v >= 60) { puts("INFTY"); return 0; // is_inf = true; // v = 0; } st[rr] += 1LL << v; if (st[rr] > thres) { puts("INFTY"); return 0; // is_inf = true; // st.back() = 0; } } else { st[++rr] = 0; // st.push_back(0); } } // while (st.size() > 1) st[0] += 1; if (rr) st[0] += 1; // auto ret = st.front(); // if (ret > thres) is_inf = true; if (st[0] > thres) { puts("INFTY"); } else { printf("%lld\n", st[0]); } }