답안 #105207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105207 2019-04-11T01:16:12 Z puyu_liao Boat (APIO16_boat) C++14
9 / 100
477 ms 640 KB
#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 505
#define C 2000
#define int int64_t
const int MOD = 1000000007;
vector<int> ds;
int a[N],b[N];
int dp[N];
int fact[C];
int ifact[C];

int powmo(int a,int b,int m){
	int r = 1;
	for(;b;b>>=1){
		if(b&1) r = r*a % m;
		a = a*a % m;
	}
	return r;
}

inline int CC(int n,int r){
	return fact[n] * ifact[r] % MOD * ifact[n-r] % MOD;
}

int32_t main()
{
	fact[0] = 1;
	for(int i=1;i<C;i++) fact[i] = i * fact[i-1] % MOD;
	ifact[C-1] = powmo(fact[C-1],MOD-2,MOD);
	for(int i=C-2;i>=0;i--) ifact[i] = ifact[i+1] * (i+1) % MOD;
	IOS;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i] >> b[i];
		ds.push_back(a[i]);
		ds.push_back(b[i]+1);
	}
	sort(ds.begin(),ds.end());
	ds.resize(unique(ds.begin(),ds.end()) - ds.begin());
	for(int i=1;i<=n;i++){
		a[i] = (int)(lower_bound(ds.begin(),ds.end(),a[i]) - ds.begin());
		b[i] = (int)(lower_bound(ds.begin(),ds.end(),b[i]+1) - ds.begin());		
	}
	dp[0] = 1;
	for(int i=0;i+1<ds.size();i++){
		int L = ds[i+1] - ds[i];
		for(int j=n;j>0;j--) if(a[j] <= i && i < b[j]){
			int f = 0, m = 1;
			for(int k=j-1;k>=0;k--){
				(f += CC(L+m-1,m) * dp[k]) %= MOD;
				if(a[k] <= i && i < b[k]) m++;
			}
			(dp[j] += f) %= MOD;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++) (ans += dp[i]) %= MOD;
	cout << ans << '\n';
  return 0;
}

Compilation message

boat.cpp: In function 'int32_t main()':
boat.cpp:49:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i+1<ds.size();i++){
              ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 335 ms 468 KB Output is correct
22 Correct 306 ms 384 KB Output is correct
23 Correct 298 ms 384 KB Output is correct
24 Correct 359 ms 384 KB Output is correct
25 Correct 298 ms 384 KB Output is correct
26 Correct 452 ms 504 KB Output is correct
27 Correct 477 ms 504 KB Output is correct
28 Correct 439 ms 384 KB Output is correct
29 Correct 452 ms 504 KB Output is correct
30 Runtime error 6 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 335 ms 468 KB Output is correct
22 Correct 306 ms 384 KB Output is correct
23 Correct 298 ms 384 KB Output is correct
24 Correct 359 ms 384 KB Output is correct
25 Correct 298 ms 384 KB Output is correct
26 Correct 452 ms 504 KB Output is correct
27 Correct 477 ms 504 KB Output is correct
28 Correct 439 ms 384 KB Output is correct
29 Correct 452 ms 504 KB Output is correct
30 Runtime error 6 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Halted 0 ms 0 KB -