結果
| 問題 |
No.2539 スライムゲーム
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-11-10 23:12:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 1,000 ms |
| コード長 | 1,038 bytes |
| コンパイル時間 | 1,022 ms |
| コンパイル使用メモリ | 88,932 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-26 02:12:49 |
| 合計ジャッジ時間 | 1,966 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
string s;
cin >> s;
vector<long long> st{0};
bool is_inf = false;
constexpr long long thres = 1000000000000000000LL;
for (int i = (int)s.size() - 1; i >= 0; --i) {
if (s.at(i) == '(') {
if (st.size() == 1) {
st.back() += 1;
break;
}
auto v = st.back();
st.pop_back();
if (v >= 60) {
is_inf = true;
v = 0;
}
st.back() += 1LL << v;
if (st.back() > thres) {
is_inf = true;
st.back() = 0;
}
} else {
st.push_back(0);
}
}
while (st.size() > 1) st.pop_back(), st.back() += 1;
auto ret = st.back();
if (ret > thres) is_inf = true;
if (is_inf) {
puts("INFTY");
} else {
cout << ret << endl;
}
}
hitonanode