Submission #971955

#TimeUsernameProblemLanguageResultExecution timeMemory
971955vjudge1Relativnost (COCI15_relativnost)C++17
140 / 140
2649 ms30136 KiB
//hivongAC=))) #include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 10007; const int mx = 1e5 + 5; int n, c, q; int v; int ap, bp; int a[mx], b[mx]; struct Node{ int chosen[21]; Node(){ memset(chosen, 0, sizeof(chosen)); } Node operator + (const Node& lr){ Node res; for (int i = 0; i <= c; i++) { for (int j = 0; j <= c; j++) { res.chosen[min(c, i + j)] = (res.chosen[min(c, i + j)] + chosen[i] * lr.chosen[j]) % maxn; } } return res; } } st[3 * mx]; void build(int id, int l, int r){ if(l == r){ st[id].chosen[0] = b[l] % maxn; st[id].chosen[1] = a[r] % maxn; return; } int m = l + r >> 1; build(id * 2, l, m); build(id * 2 + 1, m + 1, r); st[id] = st[id * 2] + st[id * 2 + 1]; } void update(int id, int l, int r, int v, int ap, int bp){ if(v < l || r < v) return; if(l == r){ a[v] = ap; st[id].chosen[1] = a[v] % maxn; b[v] = bp; st[id].chosen[0] = b[v] % maxn; return; } int m = l + r >> 1; update(id * 2, l, m, v, ap, bp); update(id * 2 + 1, m + 1, r, v, ap, bp); st[id] = st[id * 2] + st[id * 2 + 1]; } int main(){ cin >> n >> c; for(int i = 1 ; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) cin >> b[i]; build(1, 1, n); cin >> q; while(q--){ cin >> v >> ap >> bp; update(1, 1, n, v, ap, bp); cout << st[1].chosen[c] << "\n"; } }

Compilation message (stderr)

relativnost.cpp: In function 'void build(int, int, int)':
relativnost.cpp:32:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |     int m = l + r >> 1;
      |             ~~^~~
relativnost.cpp: In function 'void update(int, int, int, int, int, int)':
relativnost.cpp:46:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |     int m = l + r >> 1;
      |             ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...