結果
問題 | No.2145 Segment +- |
ユーザー | 👑 Nachia |
提出日時 | 2022-12-02 21:59:32 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,055 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 73,020 KB |
最終ジャッジ日時 | 2024-04-18 05:53:39 |
合計ジャッジ時間 | 1,010 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:10:13: error: 'uint32_t' does not name a type 10 | using u32 = uint32_t; | ^~~~~~~~ main.cpp:7:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'? 6 | #include <utility> +++ |+#include <cstdint> 7 | main.cpp:12:13: error: 'uint64_t' does not name a type 12 | using u64 = uint64_t; | ^~~~~~~~ main.cpp:12:13: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <set> #include <utility> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; int main(){ int N; string S; cin >> N >> S; vector<int> sumQ = {0}; int v = 0, rev = 1, pos = 0; int hi = 0; int ans = 0; for(char c : S){ int dx = 0; sumQ.push_back(sumQ.back()); if(c == '-') dx = -1; if(c == '+') dx = 1; dx *= rev; if(c == '?'){ dx = 1; hi++; } v += dx; hi = max(hi, v); if(v < 0){ ans++; v = hi*2 + 1; rev *= -1; hi = v; } pos++; } ans = (ans + 1) / 2; cout << ans << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;