# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98702 | Dat160601 | Relativnost (COCI15_relativnost) | C++17 | 4075 ms | 23288 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;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5 + 7, mod = 10007;
struct node{
int ret[21];
} it[4 * N];
int n, c, q, a, b, x;
int pa[N], pb[N];
int read(){
char p;
while((p = getchar())){
if(p < '0' || p > '9') continue;
break;
}
int ret = p - '0';
while((p = getchar())){
if(p >= '0' && p <= '9'){
ret *= 10;
ret += p - '0';
}
else break;
}
return ret;
}
int dg[10];
void print(int x){
int cur = 0;
if(x == 0) putchar('0');
while(x > 0){
cur++;
dg[cur] = x % 10;
x /= 10;
}
for(int i = cur; i >= 1; i--){
char p = '0' + dg[i];
putchar(p);
}
putchar('\n');
}
void add(int &a, int b){
a += b;
a %= mod;
}
node merge(node a, node b){
node res;
for(int i = 0; i <= c; i++) res.ret[i] = 0;
for(int i = 0; i <= c; i++){
for(int j = 0; j <= c; j++){
add(res.ret[min(c, i + j)], a.ret[i] * b.ret[j]);
}
}
return res;
}
void update(int k, int l, int r, int pos, int a, int b){
if(l > pos || r < pos) return;
if(l == r){
it[k].ret[0] = b;
it[k].ret[1] = a;
return;
}
int mid = (l + r) >> 1;
update(k << 1, l, mid, pos, a, b);
update(k << 1 | 1, mid + 1, r, pos, a, b);
it[k] = merge(it[k << 1], it[k << 1 | 1]);
}
int main(){
n = read(), c = read();
for(int i = 1; i <= n; i++) pa[i] = read(), pa[i] %= mod;
for(int i = 1; i <= n; i++){
pb[i] = read(), pb[i] %= mod;
update(1, 1, n, i, pa[i], pb[i]);
}
q = read();
while(q --){
x = read(), a = read(), b = read();
a %= mod, b %= mod;
update(1, 1, n, x, a, b);
print(it[1].ret[c]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |