답안 #554327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554327 2022-04-28T07:08:37 Z alirezasamimi100 Boat (APIO16_boat) C++17
27 / 100
2000 ms 4308 KB
/*#pragma GCC optimize("Ofast,unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")*/
/*#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")*/
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
using point=complex<double>;
#define F first
#define S second
//#define X real()
//#define Y imag()
#define pb push_back
#define mp make_pair
#define lc v<<1
#define rc v<<1|1
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define kill(x) cout << x << '\n';exit(0)
#define killshayan kill("done!")
#define killmashtali kill("Hello, World!")
const int N=5e2+10,LN=18,M=1e6+10,SQ=700,BS=737,inf=1.05e9,NSQ=N/SQ+3;
const ll INF=1e18;
const double pi=acos(-1);
const ld ep=1e-7;
const int MH=1000696969,MD=998244353,MOD=1000000007;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,greater<pii>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,k,l[N],r[N],dp[N*2][N],temp[N],iv[N];
vector<ll> cp={0,inf};
int main(){
    fast_io;
    cin >> n;
    for(ll i=1; i<=n; i++) iv[i]=pow(i,MOD-2,MOD);
    for(ll i=1; i<=n; i++){
        cin >> l[i] >> r[i];
        r[i]++;
        cp.pb(l[i]);
        cp.pb(r[i]);
    }
    sort(cp.begin(),cp.end());
    cp.resize(unique(cp.begin(),cp.end())-cp.begin());
    for(ll i=1; i<=n; i++){
        l[i]=lower_bound(cp.begin(),cp.end(),l[i])-cp.begin();
        r[i]=lower_bound(cp.begin(),cp.end(),r[i])-cp.begin();
    }
    k=cp.size()-2;
    for(ll i=0; i<=k; i++) dp[i][0]=1;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=k; j++){
            for(ll x=n; x; x--){
                if(j>=l[i] && j<r[i]){
                    dp[j][x]=dp[j][x]+dp[j][x-1];
                    if(dp[j][x]>MOD) dp[j][x]-=MOD;
                }
            }
            dp[j][0]=dp[j-1][0];
            ll t=1,sz=cp[j]-cp[j-1];
            for(ll x=1; x<=n; x++){
                t=t*sz%MOD*iv[x]%MOD;
                sz--;
                dp[j][0]=(dp[j][0]+dp[j-1][x]*t)%MOD;
            }
        }
    }
    cout << dp[k][0]-1 << '\n';
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 4308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 4308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1108 KB Output is correct
2 Correct 24 ms 1108 KB Output is correct
3 Correct 23 ms 1108 KB Output is correct
4 Correct 24 ms 1144 KB Output is correct
5 Correct 24 ms 1108 KB Output is correct
6 Correct 24 ms 1108 KB Output is correct
7 Correct 24 ms 1108 KB Output is correct
8 Correct 24 ms 1108 KB Output is correct
9 Correct 25 ms 1108 KB Output is correct
10 Correct 25 ms 1108 KB Output is correct
11 Correct 24 ms 1136 KB Output is correct
12 Correct 25 ms 1108 KB Output is correct
13 Correct 26 ms 1108 KB Output is correct
14 Correct 23 ms 1108 KB Output is correct
15 Correct 24 ms 1108 KB Output is correct
16 Correct 14 ms 808 KB Output is correct
17 Correct 14 ms 796 KB Output is correct
18 Correct 14 ms 792 KB Output is correct
19 Correct 14 ms 724 KB Output is correct
20 Correct 13 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 4308 KB Time limit exceeded
2 Halted 0 ms 0 KB -