Submission #588368

# Submission time Handle Problem Language Result Execution time Memory
588368 2022-07-03T08:36:14 Z messiuuuuu Boat (APIO16_boat) C++17
31 / 100
604 ms 524288 KB
#include<bits/stdc++.h>
#define task "C"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 5;
const int MOD = 1e9 + 7;

int n;
int a[MAXN], b[MAXN];
vector<int> num;

void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        for (int j = a[i]; j <= b[i]; j++)
            num.pb(j);
    }
}

void NenSo()
{
    sort(num.begin(), num.end());
    num.erase(unique(num.begin(), num.end()), num.end());
}

int nen(int x)
{
    return lower_bound(num.begin(), num.end(), x) - num.begin() + 1;
}

struct BIT
{
    vector<int> fe;
    int sz;
    void Init(int _sz)
    {
        sz = _sz;
        fe.resize(sz + 1, 0);
    }

    void add(int id, int val)
    {
        for (; id <= sz; id += id & -id)
        {
            fe[id] += val;
            fe[id] %= MOD;
        }
    }

    int get(int l)
    {
        int res = 0;
        for (; l; l -= l & -l)
        {
            res += fe[l];
            res %= MOD;
        }
        return res;
    }
};

void Solve()
{
    NenSo();
    BIT bit;
    bit.Init(num.size());
    for (int i = 1; i <= n; i++)
    {
        for (int j = b[i]; j >= a[i]; j--)
        {
            bit.add(nen(j), (bit.get(nen(j) - 1) + 1) % MOD);
        }
    }
    cout << bit.get(num.size());
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen(task".INP","r"))
    {
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    Input();
    Solve();
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:91:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 97 ms 4556 KB Output is correct
22 Correct 100 ms 4556 KB Output is correct
23 Correct 94 ms 4556 KB Output is correct
24 Correct 108 ms 4556 KB Output is correct
25 Correct 102 ms 4508 KB Output is correct
26 Correct 102 ms 4680 KB Output is correct
27 Correct 105 ms 4556 KB Output is correct
28 Correct 105 ms 4556 KB Output is correct
29 Correct 104 ms 4556 KB Output is correct
30 Correct 143 ms 8232 KB Output is correct
31 Correct 165 ms 8140 KB Output is correct
32 Correct 156 ms 8240 KB Output is correct
33 Correct 143 ms 7980 KB Output is correct
34 Correct 162 ms 8004 KB Output is correct
35 Correct 151 ms 7708 KB Output is correct
36 Correct 154 ms 7952 KB Output is correct
37 Correct 178 ms 7992 KB Output is correct
38 Correct 162 ms 7740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 604 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 97 ms 4556 KB Output is correct
22 Correct 100 ms 4556 KB Output is correct
23 Correct 94 ms 4556 KB Output is correct
24 Correct 108 ms 4556 KB Output is correct
25 Correct 102 ms 4508 KB Output is correct
26 Correct 102 ms 4680 KB Output is correct
27 Correct 105 ms 4556 KB Output is correct
28 Correct 105 ms 4556 KB Output is correct
29 Correct 104 ms 4556 KB Output is correct
30 Correct 143 ms 8232 KB Output is correct
31 Correct 165 ms 8140 KB Output is correct
32 Correct 156 ms 8240 KB Output is correct
33 Correct 143 ms 7980 KB Output is correct
34 Correct 162 ms 8004 KB Output is correct
35 Correct 151 ms 7708 KB Output is correct
36 Correct 154 ms 7952 KB Output is correct
37 Correct 178 ms 7992 KB Output is correct
38 Correct 162 ms 7740 KB Output is correct
39 Runtime error 604 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -