Submission #98684

#TimeUsernameProblemLanguageResultExecution timeMemory
98684HellAngelRelativnost (COCI15_relativnost)C++14
70 / 140
1046 ms33792 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 1e5 + 7; const int somod = 10007; struct Node { int ans[21]; } IT[4 * maxn]; int n, c, a[maxn], b[maxn], mul[maxn]; void Add(int &a, int b) { a = (a + b) % somod; } Node Merge(Node a, Node b) { Node gau; for(int i = 0; i <= c; i++) gau.ans[i] = 0; for(int i = 0; i <= c; i++) { for(int j = 0; j <= c; j++) { Add(gau.ans[min(i + j, c)], a.ans[i] * b.ans[j]); } } return gau; } void Build(int id, int l, int r) { if(l == r) { Node gau; for(int i = 0; i <= c; i++) gau.ans[i] = 0; gau.ans[0] = b[l]; gau.ans[1] = a[l]; IT[id] = gau; return; } int mid = l + r >> 1; Build(id * 2, l, mid); Build(id * 2 + 1, mid + 1, r); IT[id] = Merge(IT[id * 2], IT[id * 2 + 1]); } void Update(int id, int l, int r, int pos, int va, int vb) { if(l == r) { IT[id].ans[0] = vb; IT[id].ans[1] = va; return; } int mid = l + r >> 1; if(pos <= mid) Update(id * 2, l, mid, pos, va, vb); else Update(id * 2 + 1, mid + 1, r, pos, va, vb); IT[id] = Merge(IT[id * 2], IT[id * 2 + 1]); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen("test.inp", "r", stdin); //freopen("test.out", "w", stdout); cin >> n >> c; for(int i = 1; i <= n; i++) cin >> a[i], a[i] %= somod; for(int i = 1; i <= n; i++) cin >> b[i], b[i] %= somod; Build(1, 1, n); int q; cin >> q; for(int i = 1; i <= q; i++) { int pos, a, b; cin >> pos >> a >> b; Update(1, 1, n, pos, a, b); cout << IT[1].ans[c] << '\n'; } }

Compilation message (stderr)

relativnost.cpp: In function 'void Build(long long int, long long int, long long int)':
relativnost.cpp:44:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
relativnost.cpp: In function 'void Update(long long int, long long int, long long int, long long int, long long int, long long int)':
relativnost.cpp:58:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...