답안 #143040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143040 2019-08-12T17:29:51 Z HellAngel Boat (APIO16_boat) C++14
9 / 100
454 ms 12468 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int maxn = 1007;
const int somod = 1e9 + 7;
int n, m, a[maxn], b[maxn];
int precal[maxn][maxn], s[maxn][maxn], cnt[maxn];
vector<int> vt;

int BIT[maxn], ans[maxn], dp[maxn][maxn], total[maxn];

int Pow(int i, int j)
{
    if(j == 0) return 1;
    int mid = Pow(i, j / 2);
    mid = mid * mid % somod;
    if(j & 1) mid = mid * i % somod;
    return mid;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        vt.push_back(a[i]);
        vt.push_back(b[i] + 1);
    }
    sort(vt.begin(), vt.end());
    vt.erase(unique(vt.begin(), vt.end()), vt.end());
    int k = vt.size();
    k--;
    for(int i = 1; i <= k; i++)
    {
        precal[i][0] = 1;
        int Dist = vt[i] - vt[i - 1];
        precal[i][1] = Dist;
        for(int j = 2; j <= n + 1; j++)
        {
            precal[i][j] = precal[i][j - 1] * (Dist + j - 1) % somod * Pow(j, somod - 2) % somod; ///figurate number
        }
    }
    for(int i = 1; i <= n; i++)
    {
        int sum = 0;
        for(int j = 1; j <= k; j++)
        {
            int sum = 0, dem = 1;
            int gau = precal[j][dem];
            if(a[i] <= vt[j - 1] && vt[j] - 1 <= b[i])
            {
                cnt[j]++;
                for(int t = i - 1; t >= 1; t--)
                {
                    sum = (sum + gau * s[t][j - 1]) % somod;
                    if(a[t] <= vt[j - 1] && vt[j] - 1 <= b[t]) gau = (gau + precal[j][++dem] - vt[j] + vt[j - 1] + somod) % somod;
                }
                sum = (sum + precal[j][cnt[j]]) % somod;
            }
            s[i][j] = (s[i][j - 1] + sum) % somod;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = (ans + s[i][k]) % somod;
    cout << ans;
}

Compilation message

boat.cpp: In function 'int32_t main()':
boat.cpp:50:13: warning: unused variable 'sum' [-Wunused-variable]
         int sum = 0;
             ^~~
boat.cpp:26:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boat.cpp:26:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 12152 KB Output is correct
2 Correct 169 ms 12256 KB Output is correct
3 Correct 169 ms 12252 KB Output is correct
4 Correct 167 ms 12468 KB Output is correct
5 Correct 168 ms 12280 KB Output is correct
6 Correct 170 ms 12304 KB Output is correct
7 Correct 168 ms 12304 KB Output is correct
8 Correct 168 ms 12252 KB Output is correct
9 Correct 171 ms 12284 KB Output is correct
10 Correct 171 ms 12196 KB Output is correct
11 Correct 166 ms 12280 KB Output is correct
12 Correct 168 ms 12280 KB Output is correct
13 Correct 167 ms 12284 KB Output is correct
14 Correct 169 ms 12216 KB Output is correct
15 Correct 169 ms 12304 KB Output is correct
16 Correct 35 ms 4472 KB Output is correct
17 Correct 37 ms 4728 KB Output is correct
18 Correct 35 ms 4600 KB Output is correct
19 Correct 37 ms 4600 KB Output is correct
20 Correct 36 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 12152 KB Output is correct
2 Correct 169 ms 12256 KB Output is correct
3 Correct 169 ms 12252 KB Output is correct
4 Correct 167 ms 12468 KB Output is correct
5 Correct 168 ms 12280 KB Output is correct
6 Correct 170 ms 12304 KB Output is correct
7 Correct 168 ms 12304 KB Output is correct
8 Correct 168 ms 12252 KB Output is correct
9 Correct 171 ms 12284 KB Output is correct
10 Correct 171 ms 12196 KB Output is correct
11 Correct 166 ms 12280 KB Output is correct
12 Correct 168 ms 12280 KB Output is correct
13 Correct 167 ms 12284 KB Output is correct
14 Correct 169 ms 12216 KB Output is correct
15 Correct 169 ms 12304 KB Output is correct
16 Correct 35 ms 4472 KB Output is correct
17 Correct 37 ms 4728 KB Output is correct
18 Correct 35 ms 4600 KB Output is correct
19 Correct 37 ms 4600 KB Output is correct
20 Correct 36 ms 4600 KB Output is correct
21 Incorrect 454 ms 11612 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 12152 KB Output is correct
2 Correct 169 ms 12256 KB Output is correct
3 Correct 169 ms 12252 KB Output is correct
4 Correct 167 ms 12468 KB Output is correct
5 Correct 168 ms 12280 KB Output is correct
6 Correct 170 ms 12304 KB Output is correct
7 Correct 168 ms 12304 KB Output is correct
8 Correct 168 ms 12252 KB Output is correct
9 Correct 171 ms 12284 KB Output is correct
10 Correct 171 ms 12196 KB Output is correct
11 Correct 166 ms 12280 KB Output is correct
12 Correct 168 ms 12280 KB Output is correct
13 Correct 167 ms 12284 KB Output is correct
14 Correct 169 ms 12216 KB Output is correct
15 Correct 169 ms 12304 KB Output is correct
16 Correct 35 ms 4472 KB Output is correct
17 Correct 37 ms 4728 KB Output is correct
18 Correct 35 ms 4600 KB Output is correct
19 Correct 37 ms 4600 KB Output is correct
20 Correct 36 ms 4600 KB Output is correct
21 Incorrect 454 ms 11612 KB Output isn't correct
22 Halted 0 ms 0 KB -