답안 #48372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48372 2018-05-12T09:31:14 Z BThero Boat (APIO16_boat) C++17
9 / 100
2000 ms 2668 KB
// Why am I so stupid? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

typedef long long ll;

using namespace std;

const int mod = 1e9+7;

pair <int, int> l[505];

pair <int, int> r[505];

int dp[505][1005];

int ans;

int n;

void addMod(int &a, int b) {
    a += b;

    if (mod <= a) {
        a -= mod;
    }
}

void compress() {
    vector <int> vv;

    for (int i = 1; i <= n; ++i) {
        vv.pb(l[i].fi);
        vv.pb(r[i].fi);
    }

    sort(all(vv));
    vv.resize(unique(all(vv)) - vv.begin());

    for (int i = 1; i <= n; ++i) {
        l[i].se = upper_bound(all(vv), l[i].fi) - vv.begin();
        r[i].se = upper_bound(all(vv), r[i].fi) - vv.begin();
    }
}

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d %d", &l[i].fi, &r[i].fi);
    }

    compress();

    for (int i = 1; i <= n; ++i) {
        for (int last = l[i].se; last <= r[i].se; ++last) {
            dp[i][last] = 1;

            for (int j = 1; j < i; ++j) {
                for (int prelast = l[j].se; prelast <= r[j].se; ++prelast) {
                    if (prelast < last) {
                        addMod(dp[i][last], dp[j][prelast]);
                    }
                }
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int last = l[i].se; last <= r[i].se; ++last) {
            addMod(ans, dp[i][last]);
        }
    }

    printf("%d\n", ans);
}

int main() {
#ifdef BThero
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Compilation message

boat.cpp: In function 'void solve()':
boat.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
boat.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &l[i].fi, &r[i].fi);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2168 KB Output is correct
2 Correct 3 ms 2168 KB Output is correct
3 Correct 4 ms 2232 KB Output is correct
4 Correct 4 ms 2280 KB Output is correct
5 Correct 4 ms 2296 KB Output is correct
6 Correct 5 ms 2424 KB Output is correct
7 Correct 3 ms 2504 KB Output is correct
8 Correct 4 ms 2504 KB Output is correct
9 Correct 3 ms 2540 KB Output is correct
10 Correct 5 ms 2540 KB Output is correct
11 Correct 4 ms 2544 KB Output is correct
12 Correct 4 ms 2668 KB Output is correct
13 Correct 4 ms 2668 KB Output is correct
14 Correct 4 ms 2668 KB Output is correct
15 Correct 3 ms 2668 KB Output is correct
16 Correct 4 ms 2668 KB Output is correct
17 Correct 4 ms 2668 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2668 KB Output is correct
20 Correct 4 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2168 KB Output is correct
2 Correct 3 ms 2168 KB Output is correct
3 Correct 4 ms 2232 KB Output is correct
4 Correct 4 ms 2280 KB Output is correct
5 Correct 4 ms 2296 KB Output is correct
6 Correct 5 ms 2424 KB Output is correct
7 Correct 3 ms 2504 KB Output is correct
8 Correct 4 ms 2504 KB Output is correct
9 Correct 3 ms 2540 KB Output is correct
10 Correct 5 ms 2540 KB Output is correct
11 Correct 4 ms 2544 KB Output is correct
12 Correct 4 ms 2668 KB Output is correct
13 Correct 4 ms 2668 KB Output is correct
14 Correct 4 ms 2668 KB Output is correct
15 Correct 3 ms 2668 KB Output is correct
16 Correct 4 ms 2668 KB Output is correct
17 Correct 4 ms 2668 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2668 KB Output is correct
20 Correct 4 ms 2668 KB Output is correct
21 Execution timed out 2062 ms 2668 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2168 KB Output is correct
2 Correct 3 ms 2168 KB Output is correct
3 Correct 4 ms 2232 KB Output is correct
4 Correct 4 ms 2280 KB Output is correct
5 Correct 4 ms 2296 KB Output is correct
6 Correct 5 ms 2424 KB Output is correct
7 Correct 3 ms 2504 KB Output is correct
8 Correct 4 ms 2504 KB Output is correct
9 Correct 3 ms 2540 KB Output is correct
10 Correct 5 ms 2540 KB Output is correct
11 Correct 4 ms 2544 KB Output is correct
12 Correct 4 ms 2668 KB Output is correct
13 Correct 4 ms 2668 KB Output is correct
14 Correct 4 ms 2668 KB Output is correct
15 Correct 3 ms 2668 KB Output is correct
16 Correct 4 ms 2668 KB Output is correct
17 Correct 4 ms 2668 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2668 KB Output is correct
20 Correct 4 ms 2668 KB Output is correct
21 Execution timed out 2062 ms 2668 KB Time limit exceeded
22 Halted 0 ms 0 KB -