# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
485878 | leductoan | Relativnost (COCI15_relativnost) | C++14 | 4066 ms | 16124 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define task "sol"
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define zs(v) ((int)(v).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define CNTBIT __builtin_popcountll
#define ALL(v) (v).begin(),(v).end()
#define endl '\n'
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[4]={-1, 0, 1, 0}, dy[4]={0, 1, 0, -1};
const int dxx[8]={-1, -1, 0, 1, 1, 1, 0, -1}, dyy[8]={0, 1, 1, 1, 0, -1, -1, -1};
const ll mod = 10007; /// 998244353
const ll base = 331;
const int N=1e5+1;
int n,c,a[N],b[N];
short st[N<<2][21];
void join(int p, short dp[21], short f[21], short g[21])
{
for (int i=0;i<=c;++i) dp[i]=0;
for (int i=0;i<=c;++i) if (f[i])
for (int j=0;j<=c;++j) if (g[j])
{
int k=min(i+j,c);
dp[k]+=(int)f[i]*g[j]%mod*b[p]%mod;
k++;
k=min(k,c);
dp[k]+=(int)f[i]*g[j]%mod*a[p]%mod;
dp[k]%=mod;
}
}
void update(int i, int l, int r, int p)
{
if (l==r)
{
st[i][0]=1;
for (int j=1;j<=c;++j) st[i][j]=0;
return;
}
int mid=(l+r)/2;
if (p<=mid) update(i<<1,l,mid,p);
else update(i<<1|1,mid+1,r,p);
join(mid+1, st[i],st[i<<1],st[i<<1|1]);
// cout<<i<<" "<<l<<" "<<r<<" "<<st[i][0]<<" "<<st[i][1]<<" "<<st[i][2]<<endl;
}
void gogo()
{
cin>>n>>c;
for (int i=1;i<=n;++i) cin>>a[i], a[i]%=mod;
for (int i=1;i<=n;++i) cin>>b[i], b[i]%=mod;
for (int i=0;i<=n;++i) update(1,0,n,i);
int q;
cin>>q;
while (q--)
{
int i,x,y;
cin>>i>>x>>y;
a[i]=x, b[i]=y;
a[i]%=mod;
b[i]%=mod;
// cout<<a[i]<<" "<<b[i]<<endl;
update(1,0,n,i);
cout<<st[1][c]<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
gogo();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |