답안 #241642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241642 2020-06-25T01:15:40 Z WhaleVomit Boat (APIO16_boat) C++14
9 / 100
13 ms 8320 KB
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

const ll MOD = 1000000007;
const int MAX_N = 505;
int n;
pi arr[MAX_N];
ll dp[MAX_N][4*MAX_N];

bool cont(pi p1, pi p2) {
    return p2.f <= p1.f && p1.s <= p2.s;
}

int len(pi p) {
    return p.s - p.f + 1;
}

int main() { FAST
    cin >> n;
    M00(i, n) cin >> arr[i].f >> arr[i].s;
    vi idxs;
    idxs.pb(0);
    M00(i, n) {
        idxs.pb(arr[i].f);
        idxs.pb(arr[i].s);
    }
    sort(all(idxs));
    idxs.erase(unique(all(idxs)), idxs.end());
    vector<pi> intervals;
    intervals.pb(mp(0,0));
    MOO(i, 1, sz(idxs)) {
        pi p = mp(idxs[i-1]+1, idxs[i]-1);
        if(p.f <= p.s) intervals.pb(p);
        intervals.pb(mp(idxs[i], idxs[i]));
    }
    sort(all(intervals));
    dp[0][0] = 1;
    M00(i, sz(intervals)) {
        if(cont(intervals[i], arr[0])) dp[0][i] = len(intervals[i]);
    }
    MOO(i, 1, n) {
        M00(j, sz(intervals)) dp[i][j] = dp[i-1][j];
        ll cursum = 0;
        M00(j, sz(intervals)) {
            if(cont(intervals[j], arr[i])) {
                dp[i][j] += (cursum * len(intervals[j])) % MOD;
                dp[i][j] %= MOD;
            }
            cursum += dp[i-1][j];
            cursum %= MOD;
        }
    }
    ll res = MOD-1;
    M00(i, sz(intervals)) {
        res += dp[n-1][i];
        res %= MOD;
    }
    finish(res);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 6272 KB Output is correct
2 Correct 11 ms 6272 KB Output is correct
3 Correct 11 ms 6272 KB Output is correct
4 Correct 10 ms 6272 KB Output is correct
5 Correct 11 ms 6272 KB Output is correct
6 Correct 11 ms 6272 KB Output is correct
7 Correct 10 ms 6272 KB Output is correct
8 Correct 10 ms 6272 KB Output is correct
9 Correct 10 ms 6272 KB Output is correct
10 Correct 10 ms 6272 KB Output is correct
11 Correct 10 ms 6272 KB Output is correct
12 Correct 10 ms 6272 KB Output is correct
13 Correct 11 ms 6272 KB Output is correct
14 Correct 10 ms 6272 KB Output is correct
15 Correct 10 ms 6272 KB Output is correct
16 Correct 7 ms 3072 KB Output is correct
17 Correct 7 ms 3072 KB Output is correct
18 Correct 6 ms 3072 KB Output is correct
19 Correct 7 ms 3072 KB Output is correct
20 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 6272 KB Output is correct
2 Correct 11 ms 6272 KB Output is correct
3 Correct 11 ms 6272 KB Output is correct
4 Correct 10 ms 6272 KB Output is correct
5 Correct 11 ms 6272 KB Output is correct
6 Correct 11 ms 6272 KB Output is correct
7 Correct 10 ms 6272 KB Output is correct
8 Correct 10 ms 6272 KB Output is correct
9 Correct 10 ms 6272 KB Output is correct
10 Correct 10 ms 6272 KB Output is correct
11 Correct 10 ms 6272 KB Output is correct
12 Correct 10 ms 6272 KB Output is correct
13 Correct 11 ms 6272 KB Output is correct
14 Correct 10 ms 6272 KB Output is correct
15 Correct 10 ms 6272 KB Output is correct
16 Correct 7 ms 3072 KB Output is correct
17 Correct 7 ms 3072 KB Output is correct
18 Correct 6 ms 3072 KB Output is correct
19 Correct 7 ms 3072 KB Output is correct
20 Correct 6 ms 3072 KB Output is correct
21 Incorrect 13 ms 8320 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 6272 KB Output is correct
2 Correct 11 ms 6272 KB Output is correct
3 Correct 11 ms 6272 KB Output is correct
4 Correct 10 ms 6272 KB Output is correct
5 Correct 11 ms 6272 KB Output is correct
6 Correct 11 ms 6272 KB Output is correct
7 Correct 10 ms 6272 KB Output is correct
8 Correct 10 ms 6272 KB Output is correct
9 Correct 10 ms 6272 KB Output is correct
10 Correct 10 ms 6272 KB Output is correct
11 Correct 10 ms 6272 KB Output is correct
12 Correct 10 ms 6272 KB Output is correct
13 Correct 11 ms 6272 KB Output is correct
14 Correct 10 ms 6272 KB Output is correct
15 Correct 10 ms 6272 KB Output is correct
16 Correct 7 ms 3072 KB Output is correct
17 Correct 7 ms 3072 KB Output is correct
18 Correct 6 ms 3072 KB Output is correct
19 Correct 7 ms 3072 KB Output is correct
20 Correct 6 ms 3072 KB Output is correct
21 Incorrect 13 ms 8320 KB Output isn't correct
22 Halted 0 ms 0 KB -