제출 #485878

#제출 시각아이디문제언어결과실행 시간메모리
485878leductoanRelativnost (COCI15_relativnost)C++14
126 / 140
4066 ms16124 KiB
#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) 메시지

relativnost.cpp: In function 'int main()':
relativnost.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
relativnost.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...