| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 973058 | TAhmed33 | Žarulje (COI15_zarulje) | C++98 | 2 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 n, k, a[200001];
map <pair <int, int>, int> dp;
int ans (int l, int r) {
if (l == 1 || r == n) {
return 1;
}
if (dp.count({l, r})) return dp[{l, r}];
int sum = 0;
int x = max(a[l - 1], a[r + 1]);
if (a[l - 1] == x) sum = add(sum, ans(l - 1, r));
if (a[r + 1] == x) sum = add(sum, ans(l, r + 1));
return dp[{l, r}] = sum;
}
void solve () {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
while (k--) {
int x; cin >> x;
cout << ans(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();
}
컴파일 시 표준 에러 (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... | ||||
