# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
143004 | 2019-08-12T14:42:38 Z | HellAngel | Boat (APIO16_boat) | C++14 | 414 ms | 12408 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]; 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; if(a[i] <= vt[j - 1] && vt[j] - 1 <= b[i]) { for(int t = i - 1; t >= 1; t--) { sum = (sum + precal[j][dem] * s[t][j - 1]) % somod; if(a[k] <= vt[j - 1] && vt[j] - 1 <= b[k]) dem++; } sum = (sum + vt[j] - vt[j - 1]) % 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 166 ms | 12152 KB | Output is correct |
2 | Correct | 167 ms | 12152 KB | Output is correct |
3 | Correct | 168 ms | 12280 KB | Output is correct |
4 | Correct | 165 ms | 12152 KB | Output is correct |
5 | Correct | 167 ms | 12260 KB | Output is correct |
6 | Correct | 167 ms | 12200 KB | Output is correct |
7 | Correct | 167 ms | 12152 KB | Output is correct |
8 | Correct | 166 ms | 12152 KB | Output is correct |
9 | Correct | 166 ms | 12152 KB | Output is correct |
10 | Correct | 168 ms | 12208 KB | Output is correct |
11 | Correct | 166 ms | 12152 KB | Output is correct |
12 | Correct | 168 ms | 12228 KB | Output is correct |
13 | Correct | 167 ms | 12152 KB | Output is correct |
14 | Correct | 167 ms | 12280 KB | Output is correct |
15 | Correct | 167 ms | 12408 KB | Output is correct |
16 | Correct | 36 ms | 4472 KB | Output is correct |
17 | Correct | 37 ms | 4600 KB | Output is correct |
18 | Correct | 35 ms | 4472 KB | Output is correct |
19 | Correct | 37 ms | 4600 KB | Output is correct |
20 | Correct | 35 ms | 4600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 166 ms | 12152 KB | Output is correct |
2 | Correct | 167 ms | 12152 KB | Output is correct |
3 | Correct | 168 ms | 12280 KB | Output is correct |
4 | Correct | 165 ms | 12152 KB | Output is correct |
5 | Correct | 167 ms | 12260 KB | Output is correct |
6 | Correct | 167 ms | 12200 KB | Output is correct |
7 | Correct | 167 ms | 12152 KB | Output is correct |
8 | Correct | 166 ms | 12152 KB | Output is correct |
9 | Correct | 166 ms | 12152 KB | Output is correct |
10 | Correct | 168 ms | 12208 KB | Output is correct |
11 | Correct | 166 ms | 12152 KB | Output is correct |
12 | Correct | 168 ms | 12228 KB | Output is correct |
13 | Correct | 167 ms | 12152 KB | Output is correct |
14 | Correct | 167 ms | 12280 KB | Output is correct |
15 | Correct | 167 ms | 12408 KB | Output is correct |
16 | Correct | 36 ms | 4472 KB | Output is correct |
17 | Correct | 37 ms | 4600 KB | Output is correct |
18 | Correct | 35 ms | 4472 KB | Output is correct |
19 | Correct | 37 ms | 4600 KB | Output is correct |
20 | Correct | 35 ms | 4600 KB | Output is correct |
21 | Incorrect | 414 ms | 11624 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 1788 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 166 ms | 12152 KB | Output is correct |
2 | Correct | 167 ms | 12152 KB | Output is correct |
3 | Correct | 168 ms | 12280 KB | Output is correct |
4 | Correct | 165 ms | 12152 KB | Output is correct |
5 | Correct | 167 ms | 12260 KB | Output is correct |
6 | Correct | 167 ms | 12200 KB | Output is correct |
7 | Correct | 167 ms | 12152 KB | Output is correct |
8 | Correct | 166 ms | 12152 KB | Output is correct |
9 | Correct | 166 ms | 12152 KB | Output is correct |
10 | Correct | 168 ms | 12208 KB | Output is correct |
11 | Correct | 166 ms | 12152 KB | Output is correct |
12 | Correct | 168 ms | 12228 KB | Output is correct |
13 | Correct | 167 ms | 12152 KB | Output is correct |
14 | Correct | 167 ms | 12280 KB | Output is correct |
15 | Correct | 167 ms | 12408 KB | Output is correct |
16 | Correct | 36 ms | 4472 KB | Output is correct |
17 | Correct | 37 ms | 4600 KB | Output is correct |
18 | Correct | 35 ms | 4472 KB | Output is correct |
19 | Correct | 37 ms | 4600 KB | Output is correct |
20 | Correct | 35 ms | 4600 KB | Output is correct |
21 | Incorrect | 414 ms | 11624 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |