Submission #1032197

#TimeUsernameProblemLanguageResultExecution timeMemory
1032197giorgitsibadzeRelativnost (COCI15_relativnost)C++14
0 / 140
2333 ms50804 KiB
#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(c, i + j)] += 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) { if(tl == tr) { (t[v][1] = a[x]) %= mod; (t[v][0] = b[x]) %= mod; return; } int tm = (tl + tr) / 2; if(x <= tm) { update(2 * v, tl, tm, x); } else update(2 * v + 1, tm + 1, tr, x); 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; while(q--) { int p; cin >> p >> a[p] >> b[p]; update(1, 1, n, p); 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 timeMemoryGrader output
Fetching results...