| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1307068 | namhh | Boat (APIO16_boat) | C++20 | 2095 ms | 8312 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
const int N = 1e3+5;
const int MOD = 1e9+7;
int n,dp[N][N],pre[N][N];
pii a[N];
vector<int>loj;
int modpow(int a, int b){
int res = 1;
while(b){
if(b & 1) res = (res*a) % MOD;
a = (a*a) % MOD;
b >>= 1;
}
return res;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].fi >> a[i].se;
a[i].se++;
loj.push_back(a[i].fi);
loj.push_back(a[i].se);
}
sort(loj.begin(),loj.end());
loj.erase((loj.begin(),loj.end()),loj.end());
int lim = loj.size()-1;
for(int i = 0; i <= lim; i++) pre[0][i] = 1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= lim; j++){
int cur = 1;
int val = loj[j]-loj[j-1];
int num = 0;
for(int k = i; k >= 1; k--){
if(a[k].fi <= loj[j-1] && a[k].se >= loj[j]){
cur = cur*(val+num) % MOD*modpow(num+1,MOD-2);
num++;
dp[i][j] = (dp[i][j]+pre[k-1][j-1]*cur) % MOD;
}
}
}
pre[i][0] = 1;
for(int j = 1; j <= lim; j++) pre[i][j] = (pre[i][j-1]+dp[i][j]) % MOD;
}
pre[n][lim] = (pre[n][lim]-1) % MOD+MOD;
cout << pre[n][lim] % MOD;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
