# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1032173 | giorgitsibadze | Relativnost (COCI15_relativnost) | C++14 | 2424 ms | 50772 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.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
#define popb pop_back
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e4 + 7;
const int inf = 1e15;
int n, c;
int a[100001], b[100001];
int t[400001][21];
void merge(int v) {
for(int i = 0; i <= c; i++) t[v][i] = 0;
for(int i = 0; i <= c; i++) {
for(int j = 0; j <= c; j++) {
(t[v][min(i + j, c)] += t[2 * v][i] * t[2 * v + 1][j]) %= mod;
}
}
}
void build(int v, int tl, int tr) {
if(tl == tr) {
t[v][1] = a[tl] % mod;
t[v][0] = b[tl] % mod;
return;
}
int tm = (tl + tr) / 2;
build(2 * v, tl, tm);
build(2 * v + 1, tm + 1, tr);
merge(v);
}
void update(int v, int tl, int tr, int x, int val1, int val2) {
if(tl == tr) {
t[v][1] = val1 % mod;
t[v][0] = val2 % mod;
return;
}
int tm = (tl + tr) / 2;
if(x <= tm) {
update(2 * v, tl, tm, x, val1, val2);
}
else update(2 * v + 1, tm + 1, tr, x, val1, val2);
merge(v);
}
void solve() {
cin >> n >> c;
for(int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
build(1, 1, n);
int q;
cin >> q;
// cout << t[1][c] << '\n';
while(q--) {
int p;
cin >> p;
int x, y;
cin >> x >> y;
update(1, 1, n, p, x, y);
cout << t[1][c] << '\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
//cin >> t;
while(t--) {
solve();
cout << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |