Submission #24986

# Submission time Handle Problem Language Result Execution time Memory
24986 2017-06-19T15:27:06 Z gabrielsimoes Boat (APIO16_boat) C++14
0 / 100
0 ms 17652 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD = 1000000007;
const int MAXN = 500;
const int MAX = 1e6+10;

int n;
ll a[MAXN], b[MAXN];
ll dp[MAX], sum[MAX];

int main()
{
	bool test1 = 1, test2 = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld %lld", &a[i], &b[i]);
		if (a[i] >= MAX || b[i] >= MAX) test2 = 0;
		if (a[i] != b[i]) test1 = 0;
	}

	if (test1) {
		dp[0] = 1;
		for (int i = 1; i < n; i++) {
			dp[i] = dp[i-1] + 1;
			for (int k = i-1; k >= 0; k--)
				if (a[k] < a[i])
					dp[i] += dp[k];
		}

		printf("%lld\n", dp[n-1]);
	} else if (test2) {
		for (int i = 0; i < MAX; i++) sum[i] = 1;
		for (int i = 0; i < n; i++) {
			for (int k = b[i]; k >= a[i]; k--)
				dp[k] = (dp[k] + sum[k-1]) % MOD;
			for (int i = 1; i < MAX; i++)
				sum[i] = (sum[i-1] + dp[i]) % MOD;
		}

		printf("%lld\n", (sum[MAX-1] - 1 + MOD) % MOD);
	}
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
boat.cpp:18:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &a[i], &b[i]);
                                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17652 KB Output isn't correct
2 Halted 0 ms 0 KB -