QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233426#7512. Almost Prefix ConcatenationikefumyCompile Error//C++206.3kb2023-10-31 17:31:212023-10-31 17:31:21

Judging History

你现在查看的是最新测评结果

  • [2023-10-31 17:31:21]
  • 评测
  • [2023-10-31 17:31:21]
  • 提交

answer

#include<bits/stdc++.h>
#include<atcoder/string>
#include<atcoder/segtree>
using namespace std;
using namespace atcoder;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define int128 __int128_t
#define pii128 pair<int128,int128>
const int inf = 1 << 30;
const ll linf = 1e18;
const ll mod = 998244353;
const db EPS = 1e-10;
const db pi = acos(-1);
template<class T> bool chmin(T& x, T y){
    if(x > y) {
        x = y;
        return true;
    } else return false;
}
template<class T> bool chmax(T& x, T y){
    if(x < y) {
        x = y;
        return true;
    } else return false;
}

// overload macro
#define CAT( A, B ) A ## B
#define SELECT( NAME, NUM ) CAT( NAME, NUM )

#define GET_COUNT( _1, _2, _3, _4, _5, _6 /* ad nauseam */, COUNT, ... ) COUNT
#define VA_SIZE( ... ) GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 )

#define VA_SELECT( NAME, ... ) SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)

// rep(overload)
#define rep( ... ) VA_SELECT(rep, __VA_ARGS__)
#define rep2(i, n) for (int i = 0; i < int(n); i++)
#define rep3(i, a, b) for (int i = a; i < int(b); i++)
#define rep4(i, a, b, c) for (int i = a; i < int(b); i += c)

// repll(overload)
#define repll( ... ) VA_SELECT(repll, __VA_ARGS__)
#define repll2(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repll3(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define repll4(i, a, b, c) for (ll i = a; i < (ll)(b); i += c)

// rrep(overload)
#define rrep( ... ) VA_SELECT(rrep, __VA_ARGS__)    
#define rrep2(i, n) for (int i = n - 1; i >= 0; i--)
#define rrep3(i, a, b) for (int i = b - 1; i >= a; i--)
#define rrep4(i, a, b, c) for (int i = b - 1; i >= a; i -= c)

// rrepll(overload)
#define rrepll( ... ) VA_SELECT(rrepll, __VA_ARGS__)
#define rrepll2(i, n) for (ll i = (ll)(n) - 1; i >= 0ll; i--)
#define rrepll3(i, a, b) for (ll i = b - 1; i >= (ll)(a); i--)
#define rrepll4(i, a, b, c) for (ll i = b - 1; i >= (ll)(a); i -= c)

// for_earh
#define fore(e, v) for (auto&& e : v)

// vector
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2){
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        num = (num + 1) % mod;
        return *this;
    }
    constexpr modint operator ++ (int n){
        (void)n;
        modint tmp = *this;
        ++(*this);
        return tmp;
    }
    constexpr modint operator -- (){
        num = (num + mod - 1) % mod;
        return *this;
    }
    constexpr modint operator -- (int n){
        (void)n;
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    void modpow(ll y){
        modint tmp = (*this);
        (*this) = 1;
        while(y > 0){
            if(y % 2){
                (*this) *= tmp;
            }
            tmp *= tmp;
            y /= 2;
        }
    }

    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    
    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<mod>

mint modpow(mint x, ll y){
    if(y == 0) return 1;
    mint e = modpow(x, y / 2);
    e = e * e;
    return e * (y % 2 == 0 ? 1 : x);
}

int op(int x, int y) {
    return min(x, y);
}

int e() {
    return inf;
}

string S, T;
// 直前までの分割の仕方の個数, 通り数
mint cnt[1000010], sum[1000010];
// これまでの答えの伝播
mint dp[1000010], ans[1000010];
int sidx[1000010], tidx[1000010];
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> S >> T;
    string ST = S + "#" + T;
    auto sa = suffix_array(ST);
    auto v = lcp_array(ST, sa);
    
    rep (i, sa.size()) {
        if (sa[i] == (int)S.size()) continue;
        else if (sa[i] < (int)S.size()) {
            sidx[sa[i]] = i;
        } else {
            tidx[sa[i] - S.size() - 1] = i;
        }
    }

    sum[0] = 1, sum[1] = -1;
    segtree<int, op, e> st(v);
    rep (i, S.size()) {
        // 最大でどこまで伸ばせるか
        int len = 0;
        len += st.prod(min(sidx[i], tidx[0]), max(sidx[i], tidx[0]));
        if (len < (int)min(S.size() - i, T.size())) len++;
        if (len < (int)min(S.size() - i, T.size())) len += st.prod(min(sidx[len + i], tidx[len]), max(sidx[len + i], tidx[len]));
        // あり得る手前の個数を列挙
        cnt[i + 1] += cnt[i] + sum[i];
        cnt[i + len + 1] -= cnt[i] + sum[i];
        sum[i + 1] += sum[i];
        sum[i + len + 1] -= sum[i];
        // 現時点での新たな答えへの寄与
        dp[i + 1] += cnt[i] * 2 + sum[i];
        dp[i + len + 1] -= cnt[i] * 2 + sum[i];
        // 今の答えの通り数の増え方
        dp[i + 1] += dp[i];
        dp[i + len + 1] -= dp[i];
        // imosの伝播
        sum[i + 1] += sum[i];
        cnt[i + 1] += cnt[i];
        dp[i + 1] += dp[i];
    }

    cout << dp[S.size()] << endl;
}

Details

answer.code:2:9: fatal error: atcoder/string: No such file or directory
    2 | #include<atcoder/string>
      |         ^~~~~~~~~~~~~~~~
compilation terminated.