秋祭 | 静岡高校工学部



卬高杯


提出詳細

提出id提出時刻ユーザー名問題言語判定状況判定実行時間
1148582023-10-24 09:07:50FystyIcpp25/25AC58

#include <bits/stdc++.h>
#include <random>
#include <chrono>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T> void _do(T x){cerr<<x<<"\n";}
template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);}
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);

const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=3e18;

ll fpow(ll a,ll b,ll m)
{
    if(!b) return 1;
    ll tmp=1;
    for(ll cur=a;b;b>>=1,cur=cur*cur%m) if(b&1) tmp=tmp*cur%m;
    return tmp;
}
ll inv(ll a,ll m) {return fpow(a,m-2,m);}

#define MottoHayaku ios::sync_with_stdio(false);cin.tie(0);
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define F first
#define S second
#define pb push_back
#define uni(c) c.resize(distance(c.begin(),unique(c.begin(),c.end())))
#define unisort(c) sort(c.begin(),c.end()),uni(c)

const int MOD=127237991;

ll a[6][100005];
ll dp[6][100005];
void solve()
{
    int n;
    cin>>n;
    rep1(i,5) rep1(j,n) cin>>a[i][j];
    rep(i,100001) dp[0][i]=1;
    rep1(i,5)
    {
        rep1(j,n)
        {
            dp[i][a[i][j]]+=dp[i-1][a[i][j]-1];
            if(dp[i][a[i][j]]>=MOD) dp[i][a[i][j]]-=MOD;
        }
        rep1(j,100000)
        {
            dp[i][j]+=dp[i][j-1];
            if(dp[i][j]>=MOD) dp[i][j]-=MOD;
        }
    }
    cout<<dp[5][100000]<<"\n";
}

signed main()
{
    MottoHayaku
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}

sample1.txt AC 7
sample2.txt AC 8
sample3.txt AC 15
sample4.txt AC 23
sample5.txt AC 22
case1.txt AC 23
case2.txt AC 23
case3.txt AC 13
case4.txt AC 11
case5.txt AC 24
case6.txt AC 58
case7.txt AC 23
case8.txt AC 31
case9.txt AC 17
case10.txt AC 18
case11.txt AC 54
case12.txt AC 44
case13.txt AC 34
case14.txt AC 42
case15.txt AC 37
case16.txt AC 28
case17.txt AC 46
case18.txt AC 29
case19.txt AC 40
case20.txt AC 29
58 AC58 AC