# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251657 | VEGAnn | Relativnost (COCI15_relativnost) | C++14 | 4091 ms | 10872 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>
using namespace std;
typedef long long ll;
const int N = 100100;
const int C = 22;
const int md = 10007;
int n, c, a[N], b[N], f[N][C];
int mult(int x, int y) { return (x * y) % md; }
void SUM(int &x, int y){
x += y;
if (x >= md)
x -= md;
}
int main() {
#ifdef _LOCAL
freopen("in.txt","r",stdin); // freopen("output.txt","w",stdout);
#else
// freopen("mining.in","r",stdin); freopen("mining.out","w",stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
cin >> n >> c;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> b[i];
int qq; cin >> qq;
for (; qq; qq--){
int ps, an, bn; cin >> ps >> an >> bn;
a[ps] = an;
b[ps] = bn;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= c; j++)
f[i][j] = 0;
f[0][0] = 1;
for (int i = 0; i < n; i++)
for (int j = 0; j <= c; j++){
if (f[i][j] == 0) continue;
SUM(f[i + 1][min(j + 1, c)], mult(f[i][j], a[i + 1]));
SUM(f[i + 1][j], mult(f[i][j], b[i + 1]));
}
cout << f[n][c] << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |