Submission #433763

# Submission time Handle Problem Language Result Execution time Memory
433763 2021-06-20T10:32:41 Z someone Boat (APIO16_boat) C++14
9 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

struct Val {
    int i, val;
};

struct Node {
    int deb, fin, sum;
};

const int T = 9, M = 1 << T, N = 2*M, MOD = 1e9 + 7;

Node node[N];
int a[N], b[N];

int getSum(int i) {
    if(i == 1)
        return 0;
    int sum = getSum(i/2);
    if(i % 2 == 1)
        sum += node[i-1].sum;
    return sum % MOD;
}

void add(int i, int val) {
    if(i == 0)
        return;
    node[i].sum = (node[i].sum + val) % MOD;
    add(i/2, val);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    for(int i = 0; i < M; i++) {
        node[i + M].deb = i;
        node[i + M].fin = i + 1;
    }
    for(int i = M-1; i > -1; i--) {
        node[i].deb = node[i*2].deb;
        node[i].fin = node[i*2+1].fin;
    }

    int n;
    cin >> n;
    vector<Val> v;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        v.push_back({i, a[i]});
    }

    sort(v.begin(), v.end(),
    [](Val v1, Val v2) {
        return v1.val < v2.val;
    });
    int pre = v[0].val;
    v[0].val = 1;
    for(int i = 1; i < n; i++) {
        bool eq = (pre != v[i].val);
        pre = v[i].val;
        v[i].val = v[i-1].val + eq;
    }
    sort(v.begin(), v.end(),
    [](Val v1, Val v2) {
        return v1.i < v2.i;
    });

    int sum = 0;
    for(int i = 0; i < n; i++) {
        int val = getSum(v[i].val + M) + 1;
        sum = (sum + val) % MOD;
        add(v[i].val + M, val);
    }
    cout << sum;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Incorrect 1 ms 332 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Incorrect 1 ms 332 KB Output isn't correct
22 Halted 0 ms 0 KB -