# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094391 | VMaksimoski008 | Relativnost (COCI15_relativnost) | C++17 | 55 ms | 4236 KiB |
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>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 10007;
const int LOG = 20;
const int maxn = 1e5 + 5;
ll dp[1005][21];
signed main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<int> A(n+1), B(n+1);
for(int i=1; i<=n; i++) cin >> A[i];
for(int i=1; i<=n; i++) cin >> B[i];
int q; cin >> q;
while(q--) {
int p, na, nb; cin >> p >> na >> nb;
A[p] = na; B[p] = nb;
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for(int i=1; i<=n; i++) {
for(int j=0; j<=m; j++) {
if(j) dp[i][j] = (dp[i][j] + dp[i-1][j-1] * A[i]) % mod;
dp[i][j] = (dp[i][j] + dp[i-1][j] * B[i]) % mod;
if(j == m) dp[i][j] = (dp[i][j] + dp[i-1][j] * A[i]) % mod;
}
}
cout << dp[n][m] << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |