답안 #403903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403903 2021-05-13T14:52:36 Z sad Boat (APIO16_boat) C++14
0 / 100
283 ms 524292 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
int dp[502][1000009],a[500],b[500];
int n;const int mod=1e9+7;
vector<int>v;
int d(int x,int y)
{
    if(x==n)return 1;
    if(y==v.size())return 1;
    int &u=dp[x][y];
    if(u!=-1)return u;
    u=0;
    u=d(x+1,y);
    if(a[x]<=v[y]&&b[x]>=v[y])
    {
        u+=d(x+1,y+1);u%=mod;
        u+=d(x,y+1);u%=mod;
        u-=d(x+1,y+1);u+=mod;u%=mod;
    }
    else {
        u+=d(x,y+1);u%=mod;u-=d(x+1,y+1);u+=mod;u%=mod;
    }
    return u;
}
set<int>s;
int main()
{
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        for(int j=a[i];j<=b[i];j++)
        {
            s.insert(j);
        }
    }
    while(s.size()>0)
    {
        v.pb(*s.begin());
        s.erase(s.begin());
    }
    cout<<d(0,0)-1;
}

Compilation message

boat.cpp: In function 'int d(int, int)':
boat.cpp:13:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     if(y==v.size())return 1;
      |        ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 258 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 258 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 283 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 258 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -