답안 #760366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760366 2023-06-17T13:53:07 Z Username4132 Boat (APIO16_boat) C++14
0 / 100
7 ms 2260 KB
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define PB push_back

const int MAXN=510, INF=1000000009, MOD=1000000007;
int n, m, ans, le[MAXN], ri[MAXN], dp[MAXN][MAXN], sum[MAXN][MAXN];
vector<int> pt;

int main(){
    scanf("%d", &n);
    forn(i, n){
        scanf("%d %d", le+i, ri+i);
        pt.PB(le[i]), pt.PB(ri[i]);
        pt.PB(le[i]+1), pt.PB(ri[i]-1);
    }
    pt.PB(-1), pt.PB(INF);
    sort(pt.begin(), pt.end());
    pt.erase(unique(pt.begin(), pt.end()), pt.end());
    m = pt.size();
    forn(i, n) forsn(j, 1, m){
        if(pt[j]<=ri[i] && pt[j]>=le[i]){
            dp[i][j]=1;
            forn(k, i){
                dp[i][j] = ((ll)dp[i][j] + (ll)sum[k][j-1] + ((ll)(min(ri[k]+1, pt[j]) - max(pt[j-1], le[k])))*dp[k][j-1])%MOD;
            }
        }
        sum[i][j]=(sum[i][j-1]+((ll)(min(ri[i]+1, pt[j]) - max(pt[j-1], le[i])))*dp[i][j-1])%MOD;
    }
    forn(i, n) ans=(ans+sum[i][m-1])%MOD;
    printf("%d\n", ans);
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
boat.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d %d", le+i, ri+i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -