답안 #403989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403989 2021-05-13T16:20:33 Z sad Boat (APIO16_boat) C++14
9 / 100
2000 ms 311280 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][2000090],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;
      |                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 332 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 364 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 364 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 4 ms 332 KB Output is correct
16 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 332 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 364 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 364 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 4 ms 332 KB Output is correct
16 Correct 1 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 58 ms 572 KB Output is correct
22 Correct 57 ms 568 KB Output is correct
23 Correct 58 ms 564 KB Output is correct
24 Correct 60 ms 572 KB Output is correct
25 Correct 59 ms 572 KB Output is correct
26 Correct 53 ms 528 KB Output is correct
27 Correct 54 ms 460 KB Output is correct
28 Correct 54 ms 484 KB Output is correct
29 Correct 53 ms 500 KB Output is correct
30 Execution timed out 2081 ms 54428 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 311280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 332 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 364 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 364 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 4 ms 332 KB Output is correct
16 Correct 1 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 58 ms 572 KB Output is correct
22 Correct 57 ms 568 KB Output is correct
23 Correct 58 ms 564 KB Output is correct
24 Correct 60 ms 572 KB Output is correct
25 Correct 59 ms 572 KB Output is correct
26 Correct 53 ms 528 KB Output is correct
27 Correct 54 ms 460 KB Output is correct
28 Correct 54 ms 484 KB Output is correct
29 Correct 53 ms 500 KB Output is correct
30 Execution timed out 2081 ms 54428 KB Time limit exceeded
31 Halted 0 ms 0 KB -