Submission #923229

# Submission time Handle Problem Language Result Execution time Memory
923229 2024-02-07T01:53:41 Z vjudge1 Boat (APIO16_boat) C++17
31 / 100
83 ms 17860 KB
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 5e2 + 7;
const int mod = 1e9 + 7;
int n, a[N], b[N];

void add(int& x, int y) {
    if ((x+=y) >= mod) x-=mod;
}

namespace sub12 {
    const int N = 1e6 + 5008;
    struct BIT {
        int bit[N], n;
        BIT() {
            n = 0;
            REP(i, 0, N) bit[i] = 0;
        }
        void update(int p, int u) {
            for (; p <= n; p+=p & -p) bit[p] = (bit[p] + u) % mod;
        }
        int Get(int p) {
            int res = 0;
            for (; p > 0; p-=p & -p) res = (res + bit[p]) % mod;
            return res;
        }
    } bit;
    int f[N], pre[N];
    vector<int> E;
    void buildE() {
        FOR(i, 1, n)
            FOR(j, a[i], b[i]) E.push_back(j);
        sort(all(E));
        vector<int> new_E;
        for (auto x : E)
            if (new_E.empty() || new_E.back() != x) new_E.push_back(x);
        E = new_E;
    }
    void Process() {
        buildE();
        bit.n = (int)E.size();
        int m = E.size();
        FOR(i, 1, n) {
            a[i] = lower_bound(all(E), a[i]) - E.begin() + 1;
            b[i] = lower_bound(all(E), b[i]) - E.begin() + 1;
            FOR(j, a[i], b[i]) {
                f[j] = bit.Get(j - 1) + 1;
            }
            FOR(j, a[i], b[i]) bit.update(j, f[j]);
        }
        cout<<bit.Get(m);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    ll sum = 0;
    FOR(i, 1, n) {
        cin>>a[i]>>b[i];
        sum+=b[i] - a[i];
    }
    if (sum <= 1e6) {
        sub12::Process();
        return 0;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7772 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7768 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 2 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 1 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7768 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 8024 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7772 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7768 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 2 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 1 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7768 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 8024 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 50 ms 11456 KB Output is correct
22 Correct 50 ms 11728 KB Output is correct
23 Correct 46 ms 11452 KB Output is correct
24 Correct 51 ms 11456 KB Output is correct
25 Correct 60 ms 11988 KB Output is correct
26 Correct 52 ms 11728 KB Output is correct
27 Correct 52 ms 11680 KB Output is correct
28 Correct 53 ms 12100 KB Output is correct
29 Correct 53 ms 11716 KB Output is correct
30 Correct 72 ms 17344 KB Output is correct
31 Correct 83 ms 17300 KB Output is correct
32 Correct 69 ms 17860 KB Output is correct
33 Correct 69 ms 17292 KB Output is correct
34 Correct 70 ms 16848 KB Output is correct
35 Correct 77 ms 17604 KB Output is correct
36 Correct 81 ms 16064 KB Output is correct
37 Correct 81 ms 16324 KB Output is correct
38 Correct 77 ms 16576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 5720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7772 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7768 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 2 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 1 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7768 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 8024 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 50 ms 11456 KB Output is correct
22 Correct 50 ms 11728 KB Output is correct
23 Correct 46 ms 11452 KB Output is correct
24 Correct 51 ms 11456 KB Output is correct
25 Correct 60 ms 11988 KB Output is correct
26 Correct 52 ms 11728 KB Output is correct
27 Correct 52 ms 11680 KB Output is correct
28 Correct 53 ms 12100 KB Output is correct
29 Correct 53 ms 11716 KB Output is correct
30 Correct 72 ms 17344 KB Output is correct
31 Correct 83 ms 17300 KB Output is correct
32 Correct 69 ms 17860 KB Output is correct
33 Correct 69 ms 17292 KB Output is correct
34 Correct 70 ms 16848 KB Output is correct
35 Correct 77 ms 17604 KB Output is correct
36 Correct 81 ms 16064 KB Output is correct
37 Correct 81 ms 16324 KB Output is correct
38 Correct 77 ms 16576 KB Output is correct
39 Incorrect 1 ms 5720 KB Output isn't correct
40 Halted 0 ms 0 KB -