Submission #994247

# Submission time Handle Problem Language Result Execution time Memory
994247 2024-06-07T09:46:59 Z modwwe Boat (APIO16_boat) C++17
36 / 100
181 ms 6788 KB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    int a,b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c, d,e,f;

};
int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int  i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
   // fin(task),fou(task);
#endif
    NHP
    /// cin>>s1;
    ///modwwe
    phongbeo();
}
vector<int> v;
int c[1007][501];
ib a[501];
int dp[501][1007];
int modI(int a, int m) {
	return a<=1?a:(1-modI(m%a, a)*m)/a+m;
}
void phongbeo()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i].a>>a[i].b,
            v.pb(a[i].a-1),v.pb(a[i].b);
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end())-v.begin());
/// dp[0][i]=1;
    for(int i=1; i<v.size(); ++i) {
		c[1][i]=v[i]-v[i-1];
		for(int j=2; j<=n; ++j)
			c[j][i]=c[j-1][i]*(v[i]-v[i-1]+j-1)%mod2*modI(j, mod2)%mod2;
	}
    for(int i=0; i<v.size(); i++)
        dp[0][i]=1;

/// dua het tu v[i-1] ->v[i]
    for(int i=1; i<v.size(); i++)
    {
            for(int j=1; j<=n; j++)
            {
                dp[j][i]=dp[j][i-1];
                s2=1;
                if(a[j].a<=v[i-1]+1&&a[j].b>=v[i])
                {
                    for(int z=j-1; z>=0; --z)
                    {

                        dp[j][i]=(dp[j][i]+(dp[z][i-1]*c[s2][i])%mod2)%mod2;
                        if(a[z].a<=v[i-1]+1&&a[z].b>=v[i])
                            s2++;

                    }
                }
            }
    }

    s3=0;
     for(int j=1;j<=n;j++){
        s3=s3+dp[j][v.size()-1];
     }
     cout<<s3%mod2;
}

Compilation message

boat.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main()
      | ^~~~
boat.cpp: In function 'void phongbeo()':
boat.cpp:71:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for(int i=1; i<v.size(); ++i) {
      |                  ~^~~~~~~~~
boat.cpp:76:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     for(int i=0; i<v.size(); i++)
      |                  ~^~~~~~~~~
boat.cpp:80:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int i=1; i<v.size(); i++)
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 6744 KB Output is correct
2 Correct 16 ms 6640 KB Output is correct
3 Correct 15 ms 6748 KB Output is correct
4 Correct 16 ms 6748 KB Output is correct
5 Correct 16 ms 6748 KB Output is correct
6 Correct 16 ms 6644 KB Output is correct
7 Correct 15 ms 6748 KB Output is correct
8 Correct 15 ms 6748 KB Output is correct
9 Correct 15 ms 6748 KB Output is correct
10 Correct 15 ms 6748 KB Output is correct
11 Correct 15 ms 6748 KB Output is correct
12 Correct 15 ms 6748 KB Output is correct
13 Correct 15 ms 6748 KB Output is correct
14 Correct 15 ms 6788 KB Output is correct
15 Correct 15 ms 6748 KB Output is correct
16 Correct 4 ms 5876 KB Output is correct
17 Correct 4 ms 5980 KB Output is correct
18 Correct 5 ms 5872 KB Output is correct
19 Correct 4 ms 5980 KB Output is correct
20 Correct 5 ms 5980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 6744 KB Output is correct
2 Correct 16 ms 6640 KB Output is correct
3 Correct 15 ms 6748 KB Output is correct
4 Correct 16 ms 6748 KB Output is correct
5 Correct 16 ms 6748 KB Output is correct
6 Correct 16 ms 6644 KB Output is correct
7 Correct 15 ms 6748 KB Output is correct
8 Correct 15 ms 6748 KB Output is correct
9 Correct 15 ms 6748 KB Output is correct
10 Correct 15 ms 6748 KB Output is correct
11 Correct 15 ms 6748 KB Output is correct
12 Correct 15 ms 6748 KB Output is correct
13 Correct 15 ms 6748 KB Output is correct
14 Correct 15 ms 6788 KB Output is correct
15 Correct 15 ms 6748 KB Output is correct
16 Correct 4 ms 5876 KB Output is correct
17 Correct 4 ms 5980 KB Output is correct
18 Correct 5 ms 5872 KB Output is correct
19 Correct 4 ms 5980 KB Output is correct
20 Correct 5 ms 5980 KB Output is correct
21 Incorrect 181 ms 6740 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 4 ms 4956 KB Output is correct
8 Correct 4 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 3 ms 4956 KB Output is correct
11 Correct 3 ms 5028 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4820 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 6744 KB Output is correct
2 Correct 16 ms 6640 KB Output is correct
3 Correct 15 ms 6748 KB Output is correct
4 Correct 16 ms 6748 KB Output is correct
5 Correct 16 ms 6748 KB Output is correct
6 Correct 16 ms 6644 KB Output is correct
7 Correct 15 ms 6748 KB Output is correct
8 Correct 15 ms 6748 KB Output is correct
9 Correct 15 ms 6748 KB Output is correct
10 Correct 15 ms 6748 KB Output is correct
11 Correct 15 ms 6748 KB Output is correct
12 Correct 15 ms 6748 KB Output is correct
13 Correct 15 ms 6748 KB Output is correct
14 Correct 15 ms 6788 KB Output is correct
15 Correct 15 ms 6748 KB Output is correct
16 Correct 4 ms 5876 KB Output is correct
17 Correct 4 ms 5980 KB Output is correct
18 Correct 5 ms 5872 KB Output is correct
19 Correct 4 ms 5980 KB Output is correct
20 Correct 5 ms 5980 KB Output is correct
21 Incorrect 181 ms 6740 KB Output isn't correct
22 Halted 0 ms 0 KB -