답안 #739805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739805 2023-05-11T10:27:56 Z Magikarp4000 Boat (APIO16_boat) C++17
9 / 100
1168 ms 524288 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, MAXX = 1e6+10;
int n;
int l[MAXN], r[MAXN];
vector<int> uncc;
UM<int,int> cc;
US<int> vis;
int dp[MAXN][MAXX];

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];
        FOR(j,l[i],r[i]+1) add(j);
    }
    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,1,n+1) {
    //     FOR(j,0,vn) cout << dp[i][j] << ' ';
    //     cout << ln;
    // }
    int res = 0;
    FOR(i,1,n+1) res = (res+dp[i][vn-1])%INF;
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5304 KB Output is correct
2 Correct 5 ms 5332 KB Output is correct
3 Correct 6 ms 5332 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 5 ms 5332 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 5 ms 5256 KB Output is correct
9 Correct 5 ms 5332 KB Output is correct
10 Correct 5 ms 5360 KB Output is correct
11 Correct 5 ms 5332 KB Output is correct
12 Correct 5 ms 5244 KB Output is correct
13 Correct 5 ms 5332 KB Output is correct
14 Correct 5 ms 5332 KB Output is correct
15 Correct 6 ms 5332 KB Output is correct
16 Correct 3 ms 4436 KB Output is correct
17 Correct 3 ms 4436 KB Output is correct
18 Correct 3 ms 4436 KB Output is correct
19 Correct 3 ms 4436 KB Output is correct
20 Correct 3 ms 4436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5304 KB Output is correct
2 Correct 5 ms 5332 KB Output is correct
3 Correct 6 ms 5332 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 5 ms 5332 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 5 ms 5256 KB Output is correct
9 Correct 5 ms 5332 KB Output is correct
10 Correct 5 ms 5360 KB Output is correct
11 Correct 5 ms 5332 KB Output is correct
12 Correct 5 ms 5244 KB Output is correct
13 Correct 5 ms 5332 KB Output is correct
14 Correct 5 ms 5332 KB Output is correct
15 Correct 6 ms 5332 KB Output is correct
16 Correct 3 ms 4436 KB Output is correct
17 Correct 3 ms 4436 KB Output is correct
18 Correct 3 ms 4436 KB Output is correct
19 Correct 3 ms 4436 KB Output is correct
20 Correct 3 ms 4436 KB Output is correct
21 Correct 1018 ms 14936 KB Output is correct
22 Correct 985 ms 15020 KB Output is correct
23 Correct 914 ms 14924 KB Output is correct
24 Correct 1008 ms 15040 KB Output is correct
25 Correct 986 ms 14920 KB Output is correct
26 Correct 1041 ms 12300 KB Output is correct
27 Correct 1065 ms 12284 KB Output is correct
28 Correct 1052 ms 12304 KB Output is correct
29 Correct 1064 ms 12220 KB Output is correct
30 Runtime error 1168 ms 524288 KB Execution killed with signal 9
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 666 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5304 KB Output is correct
2 Correct 5 ms 5332 KB Output is correct
3 Correct 6 ms 5332 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 5 ms 5332 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 5 ms 5256 KB Output is correct
9 Correct 5 ms 5332 KB Output is correct
10 Correct 5 ms 5360 KB Output is correct
11 Correct 5 ms 5332 KB Output is correct
12 Correct 5 ms 5244 KB Output is correct
13 Correct 5 ms 5332 KB Output is correct
14 Correct 5 ms 5332 KB Output is correct
15 Correct 6 ms 5332 KB Output is correct
16 Correct 3 ms 4436 KB Output is correct
17 Correct 3 ms 4436 KB Output is correct
18 Correct 3 ms 4436 KB Output is correct
19 Correct 3 ms 4436 KB Output is correct
20 Correct 3 ms 4436 KB Output is correct
21 Correct 1018 ms 14936 KB Output is correct
22 Correct 985 ms 15020 KB Output is correct
23 Correct 914 ms 14924 KB Output is correct
24 Correct 1008 ms 15040 KB Output is correct
25 Correct 986 ms 14920 KB Output is correct
26 Correct 1041 ms 12300 KB Output is correct
27 Correct 1065 ms 12284 KB Output is correct
28 Correct 1052 ms 12304 KB Output is correct
29 Correct 1064 ms 12220 KB Output is correct
30 Runtime error 1168 ms 524288 KB Execution killed with signal 9
31 Halted 0 ms 0 KB -