結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
![]() |
提出日時 | 2025-07-25 21:25:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 2,264 bytes |
コンパイル時間 | 3,138 ms |
コンパイル使用メモリ | 288,260 KB |
実行使用メモリ | 11,452 KB |
最終ジャッジ日時 | 2025-07-25 21:25:22 |
合計ジャッジ時間 | 5,023 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int n; IN(n); string s; IN(s); vector<int> a(n); for (int i : Rep(0, n)) { if (s[i] == '+') { a[i] = i + 1; } else if (s[i] == '-') { a[i] = i - n; } } int ans = Sz(kactl::lis(a)); OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include <bits/stdc++.h> template <class T> concept MyRange = std::ranges::range<T> && !std::convertible_to<T, std::string_view>; template <class T> concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; // https://github.com/kth-competitive-programming/kactl namespace kactl { #define rep(i, a, b) for (int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; template <class I> vi lis(const vector<I>& S) { if (S.empty()) return {}; vi prev(sz(S)); typedef pair<I, int> p; vector<p> res; rep(i, 0, sz(S)) { auto it = lower_bound(all(res), p{S[i], 0}); if (it == res.end()) res.emplace_back(), it = res.end() - 1; *it = {S[i], i}; prev[i] = it == res.begin() ? 0 : (it - 1)->second; } int L = sz(res), cur = res.back().second; vi ans(L); while (L--) ans[L] = cur, cur = prev[cur]; return ans; } #undef sz #undef all #undef rep } // namespace kactl #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define Sz(r) int(size(r)) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1