답안 #946524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946524 2024-03-14T18:01:48 Z n3rm1n Boat (APIO16_boat) C++17
9 / 100
2000 ms 524288 KB
/// boat
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 505, MAXX = 1e6+10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
long long n, m;
long long a[MAXN], b[MAXN];
unordered_map < long long, long long > id;
vector < long long > g, u;
void read_hash()
{
    cin >> n;
    for (long long i = 1; i <= n; ++ i)
    {
        cin >> a[i] >> b[i];
        for (long long j = a[i]; j <= b[i]; ++ j)
            g.push_back(j);
    }
    sort(g.begin(), g.end());
    u.push_back(g[0]);
    for (long long i = 1; i < g.size(); ++ i)
    {
        if(u.back() != g[i])
            u.push_back(g[i]);
    }
    for (long long i = 0; i < u.size(); ++ i)
    {
        id[u[i]] = i+1;
    }
}

long long dp[MAXX];
const long long mod = 1e9 + 7;
long long pref[MAXX];
void solve()
{
    long long ans = 0;
    long long maxx = u.size();
    for (long long i = 1; i <= n; ++ i)
    {
        for (long long j = 1; j <= u.size(); ++ j)
            pref[j] = (pref[j-1] + dp[j]) % mod;
        for (long long j = id[b[i]]; j >= id[a[i]]; -- j)
        {
            dp[j] += pref[j-1] + 1;
            dp[j] %= mod;
        }

    }
    for (long long j = 1; j <= maxx; ++ j)
            pref[j] = (pref[j-1] + dp[j]) % mod;
    ans = pref[maxx];
    ans %= mod;
    cout << ans << endl;
}
int main()
{
    speed();

    read_hash();
    solve();
    return 0;
}

Compilation message

boat.cpp: In function 'void read_hash()':
boat.cpp:27:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (long long i = 1; i < g.size(); ++ i)
      |                           ~~^~~~~~~~~~
boat.cpp:32:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (long long i = 0; i < u.size(); ++ i)
      |                           ~~^~~~~~~~~~
boat.cpp: In function 'void solve()':
boat.cpp:47:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (long long j = 1; j <= u.size(); ++ j)
      |                               ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 480 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 628 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 480 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 628 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 55 ms 8656 KB Output is correct
22 Correct 51 ms 9420 KB Output is correct
23 Correct 49 ms 10444 KB Output is correct
24 Correct 52 ms 10188 KB Output is correct
25 Correct 54 ms 9936 KB Output is correct
26 Correct 51 ms 10192 KB Output is correct
27 Correct 52 ms 10448 KB Output is correct
28 Correct 51 ms 10700 KB Output is correct
29 Correct 50 ms 10448 KB Output is correct
30 Execution timed out 2047 ms 69640 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 330 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 480 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 628 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 55 ms 8656 KB Output is correct
22 Correct 51 ms 9420 KB Output is correct
23 Correct 49 ms 10444 KB Output is correct
24 Correct 52 ms 10188 KB Output is correct
25 Correct 54 ms 9936 KB Output is correct
26 Correct 51 ms 10192 KB Output is correct
27 Correct 52 ms 10448 KB Output is correct
28 Correct 51 ms 10700 KB Output is correct
29 Correct 50 ms 10448 KB Output is correct
30 Execution timed out 2047 ms 69640 KB Time limit exceeded
31 Halted 0 ms 0 KB -