/***************************************************************************/
/********************** LANG TU HAO HOA **********************************/
/***************************************************************************/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pii pair<int, int>
#define sz(x) ((int) x.size())
#define PB push_back
#define PF push_front
#define MP make_pair
#define ll long long
#define F first
#define S second
#define maxc 1000000007
#define MOD 10007
#define base 107
#define eps 1e-6
#define pi acos(-1)
#define N 100005
#define C 22
#define task ""
#define remain(x) ((x > MOD) ? (x - MOD) : x)
using namespace std;
int n, c, a[N], b[N], q;
ll total;
struct IT
{
ll t[N<<2][2*C];
void Upd(int l, int r, int id, int x)
{
if (l > x || r < x) return;
if (l == r)
{
t[id][0] = b[x];
t[id][1] = a[x];
return;
}
int mid = (l + r) >> 1;
Upd(l, mid, id*2, x);
Upd(mid+1, r, id*2+1, x);
FOR(i, 0, c-1) t[id][i] = 0;
FOR(i, 0, c-1)
FOR(j, 0, c-1)
t[id][i+j] += (t[id*2][i] * t[id*2+1][j]) % MOD;
}
ll Get()
{
ll res = total;
FOR(i, 0, c-1)
res = (res - t[1][i] + 1ll*MOD*MOD) % MOD;
return res;
}
} Tree;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
//freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
cin >> n >> c;
FOR(i, 1, n) cin >> a[i];
FOR(i, 1, n) cin >> b[i];
total = 1;
FOR(i, 1, n)
{
Tree.Upd(1, n, 1, i);
total = (total * (a[i]+b[i])) % MOD;
}
cin >> q;
while (q--)
{
int pos, x, y;
cin >> pos >> x >> y;
total = (total*(x+y)/(a[pos]+b[pos])) % MOD;
a[pos] = x;
b[pos] = y;
Tree.Upd(1, n, 1, pos);
cout << Tree.Get() << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1152 KB |
Output isn't correct |
2 |
Incorrect |
22 ms |
1152 KB |
Output isn't correct |
3 |
Incorrect |
38 ms |
1152 KB |
Output isn't correct |
4 |
Runtime error |
167 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
424 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
804 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
514 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
204 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
222 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
963 ms |
33792 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |