Submission #403985

# Submission time Handle Problem Language Result Execution time Memory
403985 2021-05-13T16:18:21 Z sad Boat (APIO16_boat) C++14
9 / 100
2000 ms 303596 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
int dp[2][1000090],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());
    }int m=v.size();
    for(int i=0;i<m;i++)dp[0][i]=1;
    dp[1][0]=1;
    for(int i=1;i<n+1;i++)
    {int g=i%2;
            int gg=(i+1)%2;
        for(int j=1; j<m; j++)
        {int u=0;
            u+=dp[gg][j];
            u%=mod;int x=i,y=j;
            if(a[i]<=v[j]&&b[i]>=v[j])
            {
                u+=dp[gg][y-1];
                u%=mod;
                u+=dp[g][y-1];
                u%=mod;
                u-=dp[gg][y-1];
                u+=mod;
                u%=mod;
            }
            else
            {
                u+=dp[g][y-1];
                u%=mod;
                u-=dp[gg][y-1];
                u+=mod;
                u%=mod;
            }
        dp[g][j]=u;u=0;
        }
        for(int j=0;j<m+1;j++)dp[gg][j]=0;
        dp[gg][0]=1;
    }
    int w=n%2;
    cout<<dp[w][m-1]-1;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:36:24: warning: unused variable 'x' [-Wunused-variable]
   36 |             u%=mod;int x=i,y=j;
      |                        ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 4 ms 332 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 4 ms 332 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 4 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 4 ms 332 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 4 ms 332 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 4 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 61 ms 584 KB Output is correct
22 Correct 58 ms 576 KB Output is correct
23 Correct 56 ms 580 KB Output is correct
24 Correct 60 ms 608 KB Output is correct
25 Correct 60 ms 580 KB Output is correct
26 Correct 51 ms 492 KB Output is correct
27 Correct 52 ms 460 KB Output is correct
28 Correct 51 ms 504 KB Output is correct
29 Correct 52 ms 460 KB Output is correct
30 Execution timed out 2094 ms 54460 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2096 ms 303596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 4 ms 332 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 4 ms 332 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 4 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 61 ms 584 KB Output is correct
22 Correct 58 ms 576 KB Output is correct
23 Correct 56 ms 580 KB Output is correct
24 Correct 60 ms 608 KB Output is correct
25 Correct 60 ms 580 KB Output is correct
26 Correct 51 ms 492 KB Output is correct
27 Correct 52 ms 460 KB Output is correct
28 Correct 51 ms 504 KB Output is correct
29 Correct 52 ms 460 KB Output is correct
30 Execution timed out 2094 ms 54460 KB Time limit exceeded
31 Halted 0 ms 0 KB -