# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98575 | tieunhi | Relativnost (COCI15_relativnost) | C++14 | 2702 ms | 26916 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, u, v) for (int i = u; i <= v; i++)
#define FORD(i, v, u) for (int i = v; i >= u; i--)
#define pii pair<int, int>
#define mp make_pair
#define F first
#define S second
#define PB push_back
#define N 100005
#define mod 10007
#define ll long long
#define mid (r + l)/2
using namespace std;
void inline add(int &A, int B) {A += B; if (A >= mod) A -= mod;}
void inline sub(int &A, int B) {A -= B; if (A < 0) A += mod;}
int inline mul(int A, int B) {return (1ll*A*B) % mod;}
int n, C, a[N], b[N];
struct IntervalTree
{
int t[N << 2][20];
int total[N << 2];
void Merge(int id)
{
FOR(i, 0, C) t[id][i] = 0;
FOR(i, 0, C)
FOR(j, 0, C)
if (i + j <= C)
add(t[id][i+j], mul(t[id*2][i], t[id*2+1][j]));
total[id] = mul(total[id*2], total[id*2+1]);
}
void update(int l, int r, int id, int x)
{
if (l == r)
{
t[id][0] = b[l];
t[id][1] = a[l];
total[id] = (a[l] + b[l]) % mod;
return;
}
if (x <= mid) update(l, mid, id*2, x);
else update(mid+1, r, id*2+1, x);
Merge(id);
}
int getAns()
{
int res = total[1];
FOR(i, 0, C) sub(res, t[1][i]);
return res;
}
}t;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("INP.TXT", "r", stdin);
cin >> n >> C; C--;
FOR(i, 1, n) cin >> a[i], a[i] %= mod;
FOR(i, 1, n) cin >> b[i], b[i] %= mod;
FOR(i, 1, n) t.update(1, n, 1, i);
int numQ; cin >> numQ;
while (numQ--)
{
int pos, x, y; cin >> pos >> x >> y;
a[pos] = x % mod;
b[pos] = y % mod;
t.update(1, n, 1, pos);
cout <<t.getAns()<<'\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |