結果
問題 |
No.318 学学学学学
|
ユーザー |
|
提出日時 | 2025-10-08 22:49:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 220 ms / 2,000 ms |
コード長 | 3,161 bytes |
コンパイル時間 | 5,369 ms |
コンパイル使用メモリ | 335,408 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2025-10-08 22:50:03 |
合計ジャッジ時間 | 10,404 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
// 基本 #include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; // 型名の省略 using ll = long long; template <class T> using vc = vector<T>; template <class T> using vvc = vector<vc<T>>; template <class T> using vvvc = vector<vvc<T>>; template <class T> using vvvvc = vector<vvvc<T>>; template <class T> using vvvvvc = vector<vvvvc<T>>; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; // 定数 constexpr long long MOD = 1000000007LL; template <class T> constexpr T INF = 0; template <> constexpr int INF<int> = 1001001001; template <> constexpr long long INF<long long> = 1LL << 61; template <> constexpr double INF<double> = INF<long long>; template <> constexpr long double INF<long double> = INF<long long>; // 便利関数 // 入出力処理 template <class... T> void input(T &...a) { (cin >> ... >> a); } void print() { cout << '\n'; } template <class T, class... Ts> void print(const T &a, const Ts &...b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } // 繰り返し処理 #define overload4(a, b, c, d, e, ...) e #define rep1(a) for (int i = 0; i < a; i++) #define rep2(i, a) for (int i = 0; i < a; i++) #define rep3(i, a, b) for (int i = a; i < b; i++) #define rep4(i, a, b, c) for (int i = a; i < b; i += c) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) // 配列処理 template <class T> bool operator==(const vector<T> &a, const vector<T> &b) { return (a.size() == b.size()) && equal(a.cbegin(), a.cend(), b.cbegin()); } template <class T> bool operator!=(const vector<T> &a, const vector<T> &b) { return !(a == b); } // 最小・最大処理 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class... Args> inline auto all_max(Args... args) { return max(initializer_list<common_type_t<Args...>>{args...}); } template <class... Args> inline auto all_min(Args... args) { return min(initializer_list<common_type_t<Args...>>{args...}); } // 追加ライブラリ using S = ll; using F = ll; S op(S l, S r) { return max(l, r); } S e() { return 0; } F mapping(F l, S r) { return (l == -1 ? r : l); } F composition(F l, F r) { return (l == -1 ? r : l); } F id() { return -1; }; /// ここからコードを書く int main() { cin.tie(0); int n; input(n); vc<ll> oa(n); map<ll, ll> lsi, rsi; rep(i, n) { ll a; input(a); oa[i] = a; if (lsi[a] == 0) lsi[a] = i + 1; rsi[a] = i; } lazy_segtree<S, op, e, F, mapping, composition, id> lseg(oa); auto lite = lsi.begin(); auto rite = rsi.begin(); while (lite != lsi.end()) { lseg.apply(lite->second - 1, rite->second + 1, lite->first); lite++; rite++; } rep(i, n) { cout << lseg.get(i) << " "; } cout << endl; return 0; }