Submission #230576

#TimeUsernameProblemLanguageResultExecution timeMemory
230576ParsaAlizadehRelativnost (COCI15_relativnost)C++17
0 / 140
475 ms47736 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define all(x) x.begin(), x.end() #define kill(x) return cout << x << endl, 0 #define X first #define Y second #define sep ' ' #define endl '\n' template<class T = ll> T nxt() {T x; cin >> x; return x;} ll pw(ll a, ll b, ll mod) { if (!b) return 1; if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod; return pw(a * a % mod, b / 2, mod) % mod; } const int N = 1e5 + 10; const int K = 22; const int MOD = 10007; int n, q, A[N], B[N], k, seg[N << 2][K]; void Merge(int id) { for (int i = 0; i <= k; i++) { seg[id][i] = 0; } for (int i = 0; i <= k; i++) { for (int j = 0; j <= k; j++) { seg[id][min(k, i + j)] += seg[2 * id][i] * seg[2 * id + 1][j] % MOD; seg[id][min(k, i + j)] %= MOD; } } } void Build(int id, int l, int r) { if (r - l == 1) { seg[id][0] = B[l]; seg[id][1] = A[l]; return; } int mid = (l + r) >> 1; Build(2 * id, l, mid); Build(2 * id + 1, mid, r); Merge(id); } void Update(int id, int l, int r, int ind) { if (ind < l || r <= ind) return; if (r - l == 1) { seg[id][0] = B[l]; seg[id][1] = A[l]; return; } int mid = (l + r) >> 1; if (ind < mid) Update(2 * id, l, mid, ind); else Update(2 * id + 1, mid, r, ind); Merge(id); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &(A[i])); A[i] %= MOD; } for (int i = 0; i < n; i++) { scanf("%d", &(B[i])); B[i] %= MOD; } Build(1, 0, n); scanf("%d", &q); while (q--) { int ind, a, b; cin >> ind >> a >> b; ind--; A[ind] = a % MOD; B[ind] = b % MOD; Update(1, 0, n, ind); printf("%d\n", seg[1][k]); } return 0; }

Compilation message (stderr)

relativnost.cpp: In function 'int main()':
relativnost.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
relativnost.cpp:74:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &(A[i])); A[i] %= MOD;
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:77:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &(B[i])); B[i] %= MOD;
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...