답안 #739801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739801 2023-05-11T10:16:04 Z Magikarp4000 Boat (APIO16_boat) C++17
0 / 100
4 ms 4308 KB
#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int64_t(1e9+7)
#define ln '\n' 
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;
#define int long long

const int MAXN = 5e2+1;
int n;
int l[MAXN], r[MAXN];
vector<int> uncc;
UM<int,int> cc;
US<int> vis;
int dp[MAXN][MAXN*3];

void add(int x) {
    if (!vis.count(x)) {
        vis.insert(x);
        uncc.PB(x);
    }
}

signed main() {
    OPTM;
    cin >> n;
    FOR(i,1,n+1) {
        cin >> l[i] >> r[i];
        add(l[i]); add(r[i]);
    }
    uncc.PB(0);
    sort(ALL(uncc));
    int vn = uncc.size();
    FOR(i,0,vn) cc[uncc[i]] = i;
    FOR(i,1,n+1) {
        int cl = cc[l[i]], cr = cc[r[i]];
        FOR(j,cl,cr+1) {
            dp[i][j] = 1;
            FOR(k,1,i) dp[i][j] = (dp[i][j]+dp[k][j-1])%INF;
        }
        FOR(j,1,vn) dp[i][j] = (dp[i][j]+dp[i][j-1])%INF;
    }
    // FOR(i,0,n+1) {
    //     FOR(j,0,vn) cout << dp[i][j] << ' ';
    //     cout << ln;
    // }
    int res = dp[n][vn-1];
    if (n >= 2) res = (res+dp[n-1][vn-1])%INF;
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4308 KB Output isn't correct
2 Halted 0 ms 0 KB -