답안 #45555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45555 2018-04-15T11:04:51 Z gnoor Boat (APIO16_boat) C++17
9 / 100
537 ms 4536 KB
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

map<int,int> mp;
int a[600];
int b[600];
int mod=1000000007;
int dec[1010];

long long dp[600][1010];

int main () {
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%d%d",&a[i],&b[i]);
		mp[a[i]-1];
		mp[b[i]];
	}
	int i=1;
	for (auto &ii:mp) {
		dec[i]=ii.first;
		ii.second=i++;
	}
	for (int i=0;i<n;i++) {
		a[i]=mp[a[i]-1];
		b[i]=mp[b[i]];
	}
	int nn=mp.size();

	for (int i=0;i<n;i++) {
		//printf("** %d %d\n",a[i],b[i]);
		for (int j=i-1;j>=0;j--) {
			for (int k=a[i]+1;k<=b[i];k++) {
				//printf("** %d %d %d %lld\n",i,j,k,dp[j][k-1]);
				dp[i][k]+=dp[j][k-1]*(dec[k]-dec[k-1]);
				dp[i][k]%=mod;
			}
		}
		for (int k=a[i]+1;k<=b[i];k++) {
			dp[i][k]+=(dec[k]-dec[k-1]);
			dp[i][k]+=dp[i][k-1];
			dp[i][k]%=mod;
		}
		for (int k=b[i]+1;k<=nn;k++) {
			dp[i][k]+=dp[i][k-1];
			dp[i][k]%=mod;
		}
		//for (int k=1;k<=nn;k++) {
			//printf("%lld ",dp[i][k]);
		//}
		//printf("\n");
	}
	long long ans=0;
	for (int i=0;i<n;i++) {
		ans+=dp[i][nn];
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
boat.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a[i],&b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3832 KB Output is correct
2 Correct 15 ms 3944 KB Output is correct
3 Correct 15 ms 3944 KB Output is correct
4 Correct 15 ms 4040 KB Output is correct
5 Correct 15 ms 4040 KB Output is correct
6 Correct 14 ms 4116 KB Output is correct
7 Correct 14 ms 4116 KB Output is correct
8 Correct 14 ms 4116 KB Output is correct
9 Correct 18 ms 4140 KB Output is correct
10 Correct 15 ms 4140 KB Output is correct
11 Correct 15 ms 4140 KB Output is correct
12 Correct 16 ms 4140 KB Output is correct
13 Correct 16 ms 4140 KB Output is correct
14 Correct 16 ms 4152 KB Output is correct
15 Correct 14 ms 4152 KB Output is correct
16 Correct 9 ms 4152 KB Output is correct
17 Correct 9 ms 4152 KB Output is correct
18 Correct 8 ms 4152 KB Output is correct
19 Correct 9 ms 4152 KB Output is correct
20 Correct 9 ms 4152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3832 KB Output is correct
2 Correct 15 ms 3944 KB Output is correct
3 Correct 15 ms 3944 KB Output is correct
4 Correct 15 ms 4040 KB Output is correct
5 Correct 15 ms 4040 KB Output is correct
6 Correct 14 ms 4116 KB Output is correct
7 Correct 14 ms 4116 KB Output is correct
8 Correct 14 ms 4116 KB Output is correct
9 Correct 18 ms 4140 KB Output is correct
10 Correct 15 ms 4140 KB Output is correct
11 Correct 15 ms 4140 KB Output is correct
12 Correct 16 ms 4140 KB Output is correct
13 Correct 16 ms 4140 KB Output is correct
14 Correct 16 ms 4152 KB Output is correct
15 Correct 14 ms 4152 KB Output is correct
16 Correct 9 ms 4152 KB Output is correct
17 Correct 9 ms 4152 KB Output is correct
18 Correct 8 ms 4152 KB Output is correct
19 Correct 9 ms 4152 KB Output is correct
20 Correct 9 ms 4152 KB Output is correct
21 Incorrect 537 ms 4536 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3832 KB Output is correct
2 Correct 15 ms 3944 KB Output is correct
3 Correct 15 ms 3944 KB Output is correct
4 Correct 15 ms 4040 KB Output is correct
5 Correct 15 ms 4040 KB Output is correct
6 Correct 14 ms 4116 KB Output is correct
7 Correct 14 ms 4116 KB Output is correct
8 Correct 14 ms 4116 KB Output is correct
9 Correct 18 ms 4140 KB Output is correct
10 Correct 15 ms 4140 KB Output is correct
11 Correct 15 ms 4140 KB Output is correct
12 Correct 16 ms 4140 KB Output is correct
13 Correct 16 ms 4140 KB Output is correct
14 Correct 16 ms 4152 KB Output is correct
15 Correct 14 ms 4152 KB Output is correct
16 Correct 9 ms 4152 KB Output is correct
17 Correct 9 ms 4152 KB Output is correct
18 Correct 8 ms 4152 KB Output is correct
19 Correct 9 ms 4152 KB Output is correct
20 Correct 9 ms 4152 KB Output is correct
21 Incorrect 537 ms 4536 KB Output isn't correct
22 Halted 0 ms 0 KB -