답안 #554328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554328 2022-04-28T07:10:09 Z alirezasamimi100 Boat (APIO16_boat) C++17
27 / 100
2000 ms 4724 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=6e2+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],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 2078 ms 4724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2078 ms 4724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1300 KB Output is correct
2 Correct 25 ms 1236 KB Output is correct
3 Correct 25 ms 1304 KB Output is correct
4 Correct 26 ms 1296 KB Output is correct
5 Correct 26 ms 1236 KB Output is correct
6 Correct 25 ms 1292 KB Output is correct
7 Correct 25 ms 1236 KB Output is correct
8 Correct 24 ms 1284 KB Output is correct
9 Correct 24 ms 1296 KB Output is correct
10 Correct 24 ms 1236 KB Output is correct
11 Correct 24 ms 1296 KB Output is correct
12 Correct 24 ms 1300 KB Output is correct
13 Correct 25 ms 1296 KB Output is correct
14 Correct 24 ms 1292 KB Output is correct
15 Correct 24 ms 1236 KB Output is correct
16 Correct 15 ms 892 KB Output is correct
17 Correct 14 ms 888 KB Output is correct
18 Correct 15 ms 852 KB Output is correct
19 Correct 16 ms 896 KB Output is correct
20 Correct 16 ms 872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2078 ms 4724 KB Time limit exceeded
2 Halted 0 ms 0 KB -