結果

問題 No.1512 作文
ユーザー hirono999hirono999
提出日時 2021-05-21 21:37:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 4,165 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 209,828 KB
最終ジャッジ日時 2024-04-18 14:54:24
合計ジャッジ時間 3,795 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bitset:52,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/stdc++.h:52,
                 from /home/snow/competitive-programming/competitive-programming-library/snow/template.hpp:5:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:54:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~

ソースコード

diff #

#line 2 "/home/snow/competitive-programming/competitive-programming-library/snow/template.hpp"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

constexpr long long INF = 1LL << 60;
constexpr long double PI = 3.141592653589;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define to_s to_string
#define len(v) (ll) v.size()
#define debug(x) cout << #x << ": " << (x) << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> tpl;

template <typename T = ll>
using vec = vector<T>;

template <typename T = ll>
using vec2 = vector<vector<T>>;

template <typename T = ll>
using vec3 = vector<vector<vector<T>>>;

template < typename T >
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template < typename T >
inline bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#line 4 "/home/snow/competitive-programming/competitive-programming-library/snow/io/setup.hpp"

namespace snow{

struct IoSetup {
    IoSetup() {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
        std::cout << std::fixed << std::setprecision(10);
    }
} iosetup;

} // namespace snow
#line 5 "/home/snow/competitive-programming/competitive-programming-library/snow/io/helper.hpp"

template< typename T1, typename T2 >
std::ostream &operator << (std::ostream &os, const std::pair< T1, T2 > &p) {
    os << p.first << " " << p.second;
    return os;
}

template< typename T1, typename T2 >
std::istream &operator >> (std::istream &is, std::pair< T1, T2 > &p) {
    is >> p.first >> p.second;
    return is;
}

template< typename T1, typename T2, typename T3 >
std::ostream &operator << (std::ostream &os, const std::tuple< T1, T2, T3 > &t) {
    auto &[a, b, c] = t;
    os << a << " " << b << " " << c;
    return os;
}

template< typename T1, typename T2, typename T3 >
std::istream &operator >> (std::istream &is, std::tuple< T1, T2, T3 > &t) {
    auto &[a, b, c] = t;
    is >> a >> b >> c;
    return is;
}

template< typename T >
std::ostream &operator << (std::ostream &os, const std::vector< T > &v){
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return os;
}

template< typename T >
std::istream &operator >>  (std::istream &is, std::vector< T > &v){
    for(T &in : v) is >> in;
    return is;
}

template< typename T >
std::ostream &operator << (std::ostream &os, const std::set< T > &st){
    int ct = 0;
    for(auto& s : st) os << s << (++ct != (int)st.size() ? " " : "");
    return os;
}

template<class... T>
void input(T&... a){
    (std::cin >> ... >> a);
}

void print() {
    std::cout << '\n';
}
template<class T, class... Ts>
void print(const T& a, const Ts&... b){
    std::cout << a;
    (std::cout << ... << (std::cout << ' ', b));
    std::cout << '\n';
}

int drop() {
    std::cout << '\n';
    exit(0);
}
template<class T, class... Ts>
int drop(const T& a, const Ts&... b){
    std::cout << a;
    (std::cout << ... << (std::cout << ' ', b));
    std::cout << '\n';
    exit(0);
}
#line 4 "main.cpp"
using namespace snow;

// #include "snow/algorithm/binary-search.hpp"

// #include "atcoder/modint"
// using namespace atcoder;
// using mint = modint1000000007;

bool isgood(string& s){
    rep(i, len(s) - 1){
        if(s[i] > s[i + 1]) return false;
    }
    return true;
}

int main() {
    ll N;
    cin >> N;
    vector<string> S(N);
    cin >> S;
    sort(ALL(S));

    vec<> mx(30);
    rep(i, N){
        string s = S[i];
        if(!isgood(s)) continue;

        ll a = s[0] - 'a';
        ll b = s.back() - 'a';

        ll ret = 0;
        rep(j, a + 1) chmax(ret, mx[j]);
        chmax(mx[b], ret + len(s));
    }
    print(*max_element(ALL(mx)));

    return 0;
}
0