Submission #554334

# Submission time Handle Problem Language Result Execution time Memory
554334 2022-04-28T07:14:06 Z alirezasamimi100 Boat (APIO16_boat) C++17
27 / 100
1328 ms 7900 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],wtf[N][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++){
        wtf[i][0]=1;
        ll sz=cp[i+1]-cp[i];
        for(ll j=1; j<=n; j++){
            wtf[i][j]=wtf[i][j-1]*sz%MOD*iv[j]%MOD;
            sz--;
        }
    }
    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];
            for(ll x=1; x<=n; x++){
                dp[j][0]=(dp[j][0]+dp[j-1][x]*wtf[j-1][x])%MOD;
            }
        }
    }
    cout << dp[k][0]-1 << '\n';
    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1328 ms 7900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1328 ms 7900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2132 KB Output is correct
2 Correct 13 ms 2252 KB Output is correct
3 Correct 14 ms 2256 KB Output is correct
4 Correct 13 ms 2252 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 14 ms 2248 KB Output is correct
7 Correct 14 ms 2260 KB Output is correct
8 Correct 13 ms 2252 KB Output is correct
9 Correct 14 ms 2132 KB Output is correct
10 Correct 14 ms 2256 KB Output is correct
11 Correct 13 ms 2260 KB Output is correct
12 Correct 11 ms 2132 KB Output is correct
13 Correct 12 ms 2256 KB Output is correct
14 Correct 13 ms 2256 KB Output is correct
15 Correct 12 ms 2256 KB Output is correct
16 Correct 8 ms 1364 KB Output is correct
17 Correct 8 ms 1364 KB Output is correct
18 Correct 8 ms 1436 KB Output is correct
19 Correct 8 ms 1448 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1328 ms 7900 KB Output isn't correct
2 Halted 0 ms 0 KB -