Submission #994245

# Submission time Handle Problem Language Result Execution time Memory
994245 2024-06-07T09:45:48 Z modwwe Boat (APIO16_boat) C++17
0 / 100
2 ms 348 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;
}

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++)
      |                  ~^~~~~~~~~
boat.cpp: In function 'int main()':
boat.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
boat.cpp:48:5: note: in expansion of macro 'fin'
   48 |     fin(task),fou(task);
      |     ^~~
boat.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
boat.cpp:48:15: note: in expansion of macro 'fou'
   48 |     fin(task),fou(task);
      |               ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -