Submission #890600

#TimeUsernameProblemLanguageResultExecution timeMemory
890600CookieŽarulje (COI15_zarulje)C++14
22 / 100
33 ms34396 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define sz(a) (int)a.size() #define ALL(v) v.begin(), v.end() #define ALLR(v) v.rbegin(), v.rend() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> #define mpp make_pair const ld PI = 3.14159265359; using u128 = __uint128_t; //const int x[4] = {1, -1, 0, 0}; //const int y[4] = {0, 0, 1, -1}; const ll mod = 1e9 + 7; const int mxn = 3e5 + 69, mxq = 1e5 + 5, sq = 500, mxv = 2e7 + 5; //const int base = (1 << 18); const int inf = 1e9 + 5, neg = -69420; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); //const int x[9] = {0, 1, 1, -1, -1, 2, -2, 2, -2}; //const int y[9] = {0, 2, -2, 2, -2, 1, 1, -1, -1}; int n, k; int power[mxn + 1], dp[2005][2005]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("recruit.inp", "r", stdin); //freopen("recruit.out", "w", stdout); cin >> n >> k; for(int i = 1; i <= n; i++)cin >> power[i]; dp[0][n] = dp[1][n + 1] = 1; for(int len = n; len >= 1; len--){ for(int j = 0; j + len - 1 <= n + 1; j++){ int l = j, r = j + len - 1; if(r == n + 1)dp[l][r] = dp[l - 1][r]; else if(l == 0)dp[l][r] = dp[l][r + 1]; else{ if(power[l] == power[r]){ dp[l][r] = (dp[l - 1][r] + dp[l][r + 1]) % mod; }else if(power[l] > power[r]){ dp[l][r] = dp[l - 1][r]; }else{ dp[l][r] = dp[l][r + 1]; } } } } while(k--){ int p; cin >> p; ll ans = dp[p - 1][p + 1]; cout << ans << "\n"; } return(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...