# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995471 | otarius | Relativnost (COCI15_relativnost) | C++17 | 3081 ms | 26044 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.
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template<typename T, typename V>
void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template<typename T>
void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i: x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template<typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair <int, int>
#define ull unsigned long long
// #define int long long
// #define int unsigned long long
const ll mod = 10007;
const ll weirdMod = 998244353;
const int maxN = 1e5 + 25;
int n, c, q, a[maxN], b[maxN], t[4 * maxN][21];
void build(int v, int tl, int tr) {
if (tl == tr) {
t[v][0] = b[tl] % mod;
t[v][1] = a[tl] % mod;
return;
} int tm = (tl + tr) / 2;
build(2 * v, tl, tm);
build(2 * v + 1, tm + 1, tr);
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) %= mod;
}
void update(int v, int tl, int tr, int pos) {
if (tl == tr) {
t[v][0] = b[tl] % mod;
t[v][1] = a[tl] % mod;
return;
} int tm = (tl + tr) / 2;
if (pos <= tm) update(2 * v, tl, tm, pos);
else update(2 * v + 1, tm + 1, tr, pos);
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) %= mod;
}
void solve() {
cin >> n >> c;
int cnt = 0;
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--) {
int x;
cin >> x;
cin >> a[x] >> b[x];
update(1, 1, n, x);
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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |