# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31677 | long10024070 | Relativnost (COCI15_relativnost) | C++11 | 4000 ms | 19364 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 <cstdio>
using namespace std;
const string TASK = "Relativnost";
const int Mod = 1e4 + 7;
const int maxn = 1e5 + 1;
int n,c,i,a[maxn],b[maxn],node[maxn*2][21],t,j,k;
void Enter()
{
scanf("%d%d",&n,&c);
for (i=1;i<=n;++i)
scanf("%d",&a[i]);
for (i=1;i<=n;++i)
scanf("%d",&b[i]);
}
void Update()
{
t = i + n - 1;
for (j=2;j<=c;++j)
node[t][j] = 0;
node[t][1] = a[i] % Mod;
node[t][0] = b[i] % Mod;
t >>= 1;
while (t != 0) {
for (j=0;j<=c;++j)
node[t][j] = 0;
for (j=0;j<=c;++j)
for (k=0;k<=c;++k) {
node[t][min(c,j+k)] = (node[t][min(c,j+k)] + node[t*2][j] * node[t*2+1][k]) % Mod;
}
t >>= 1;
}
}
void Init()
{
for (i=1;i<=n;++i)
Update();
}
void Solve()
{
int q,A,B;
for (scanf("%d",&q);q>0;--q) {
scanf("%d",&i);
scanf("%d%d",&a[i],&b[i]);
Update();
printf("%d\n",node[1][c]);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen((TASK+".INP").c_str(),"r",stdin);
//freopen((TASK+".OUT").c_str(),"w",stdout);
Enter();
Init();
Solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |