Submission #973001

# Submission time Handle Problem Language Result Execution time Memory
973001 2024-05-01T12:03:34 Z TAhmed33 Žarulje (COI15_zarulje) C++
0 / 100
2 ms 532 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add (int a, int b) {
	a += b; if (a >= MOD) a -= MOD;
	return a;
}
int dp[2001][2001];
int n, k, a[2001];
void solve () {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int r = n; r >= 1; r--) {
		for (int l = 1; l <= r; l++) {
			if (l == 1 && r == n) {
				dp[l][r] = 1;
				continue;
			}
			int x = max(a[l - 1], a[r + 1]);
			if (a[l - 1] == x) dp[l][r] = add(dp[l][r], dp[l - 1][r]);
			if (a[r + 1] == x) dp[l][r] = add(dp[l][r], dp[l][r + 1]);
		}
	}
	while (k--) {
		int x; cin >> x;
		cout << dp[x][x] << '\n';
	}
}
signed main () {
	 #ifndef ONLINE_JUDGE 
		freopen("input_file", "r", stdin);
		freopen("output_file", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int t = 1; //cin >> t;
	while (t--) solve();
}

Compilation message

zarulje.cpp: In function 'int main()':
zarulje.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   freopen("input_file", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
zarulje.cpp:34:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   freopen("output_file", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -