제출 #48372

#제출 시각아이디문제언어결과실행 시간메모리
48372BTheroBoat (APIO16_boat)C++17
9 / 100
2062 ms2668 KiB
// 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;
}

컴파일 시 표준 에러 (stderr) 메시지

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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...