답안 #403933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403933 2021-05-13T15:19:06 Z sad Boat (APIO16_boat) C++14
9 / 100
2000 ms 301240 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][10009],a[503],b[503];
int n;
const int mod=1e9+7;
vector<int>v;
set<int>s;
int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;v.pb(0);
    for(int i=1; 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());
    }
    for(int i=0;i<v.size();i++)dp[0][i]=1;
    for(int i=0;i<n+1;i++)dp[i][0]=1;
    for(int i=1;i<n+1;i++)
    {
        for(int j=1; j<v.size(); j++)
        {int u=0;
            u+=dp[i-1][j];
            u%=mod;int x=i,y=j;
            if(a[i]<=v[j]&&b[i]>=v[j])
            {
                u+=dp[x-1][y-1];//cout<<u<<endl;
                u%=mod;
                u+=dp[x][y-1];//cout<<dp[x][y-1]<<endl;
                u%=mod;
                u-=dp[x-1][y-1];
                u+=mod;
                u%=mod;
            }
            else
            {
                u+=dp[x][y-1];
                u%=mod;
                u-=dp[x-1][y-1];
                u+=mod;
                u%=mod;
            }
        dp[i][j]=u;u=0;
        }
    }
    cout<<dp[n][v.size()-1]-1;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<v.size();i++)dp[0][i]=1;
      |                 ~^~~~~~~~~
boat.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int j=1; j<v.size(); j++)
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3276 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 5 ms 3276 KB Output is correct
4 Correct 5 ms 3276 KB Output is correct
5 Correct 5 ms 3276 KB Output is correct
6 Correct 5 ms 3272 KB Output is correct
7 Correct 5 ms 3276 KB Output is correct
8 Correct 5 ms 3276 KB Output is correct
9 Correct 5 ms 3288 KB Output is correct
10 Correct 6 ms 3296 KB Output is correct
11 Correct 6 ms 3276 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3272 KB Output is correct
14 Correct 6 ms 3276 KB Output is correct
15 Correct 5 ms 3276 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 3 ms 2508 KB Output is correct
18 Correct 3 ms 2508 KB Output is correct
19 Correct 3 ms 2508 KB Output is correct
20 Correct 3 ms 2508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3276 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 5 ms 3276 KB Output is correct
4 Correct 5 ms 3276 KB Output is correct
5 Correct 5 ms 3276 KB Output is correct
6 Correct 5 ms 3272 KB Output is correct
7 Correct 5 ms 3276 KB Output is correct
8 Correct 5 ms 3276 KB Output is correct
9 Correct 5 ms 3288 KB Output is correct
10 Correct 6 ms 3296 KB Output is correct
11 Correct 6 ms 3276 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3272 KB Output is correct
14 Correct 6 ms 3276 KB Output is correct
15 Correct 5 ms 3276 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 3 ms 2508 KB Output is correct
18 Correct 3 ms 2508 KB Output is correct
19 Correct 3 ms 2508 KB Output is correct
20 Correct 3 ms 2508 KB Output is correct
21 Correct 64 ms 12724 KB Output is correct
22 Correct 65 ms 12652 KB Output is correct
23 Correct 63 ms 12820 KB Output is correct
24 Correct 66 ms 12740 KB Output is correct
25 Correct 78 ms 12728 KB Output is correct
26 Correct 59 ms 10080 KB Output is correct
27 Correct 58 ms 10056 KB Output is correct
28 Correct 58 ms 10132 KB Output is correct
29 Correct 56 ms 10140 KB Output is correct
30 Execution timed out 2065 ms 57760 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2033 ms 301240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3276 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 5 ms 3276 KB Output is correct
4 Correct 5 ms 3276 KB Output is correct
5 Correct 5 ms 3276 KB Output is correct
6 Correct 5 ms 3272 KB Output is correct
7 Correct 5 ms 3276 KB Output is correct
8 Correct 5 ms 3276 KB Output is correct
9 Correct 5 ms 3288 KB Output is correct
10 Correct 6 ms 3296 KB Output is correct
11 Correct 6 ms 3276 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3272 KB Output is correct
14 Correct 6 ms 3276 KB Output is correct
15 Correct 5 ms 3276 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 3 ms 2508 KB Output is correct
18 Correct 3 ms 2508 KB Output is correct
19 Correct 3 ms 2508 KB Output is correct
20 Correct 3 ms 2508 KB Output is correct
21 Correct 64 ms 12724 KB Output is correct
22 Correct 65 ms 12652 KB Output is correct
23 Correct 63 ms 12820 KB Output is correct
24 Correct 66 ms 12740 KB Output is correct
25 Correct 78 ms 12728 KB Output is correct
26 Correct 59 ms 10080 KB Output is correct
27 Correct 58 ms 10056 KB Output is correct
28 Correct 58 ms 10132 KB Output is correct
29 Correct 56 ms 10140 KB Output is correct
30 Execution timed out 2065 ms 57760 KB Time limit exceeded
31 Halted 0 ms 0 KB -