This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define FOR(v, s, e) for (int v = s; v < e; v++)
#define FOR_REV(v, s, e) for (int v = e - 1; v >= s; v--)
#define MOD 1000007
int n, ans, cmax = 1;
int pf[105][105][105];
int main() {
cin >> n;
if (n > 100) return 1;
FOR(i, 0, n) {
FOR(k, 0, n)
pf[0][i][k + 1] = pf[0][i][k] + 1;
}
FOR(i, 1, n) {
FOR(j, 0, n) {
FOR(k, 0, n) {
pf[i][j][k + 1] = (pf[i][j][k] + pf[i - 1][j][j + 1] + pf[i - 1][j + 1][j + 2] - pf[i - 1][j + 1][j + 1]) % MOD;
}
}
}
FOR_REV(i, 0, n) {
int cval;
cin >> cval;
cout << pf[i][cmax - 1][cval - 1] << '\n';
ans = (ans + pf[i][cmax - 1][cval - 1]) % MOD;
cmax = max(cmax, cval);
}
cout << (ans + 1) % MOD;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |