Submission #164337

# Submission time Handle Problem Language Result Execution time Memory
164337 2019-11-19T12:06:59 Z beso123 Relativnost (COCI15_relativnost) C++14
126 / 140
4000 ms 24220 KB
#include <bits/stdc++.h>
#define mod 10007
using namespace std;
int n,m,Q,a[100010],b[100010],t[800100][22],sum;
void update(int v){
for(int k=0;k<=m;k++)
        t[v][k]=0;
  for(int i=0;i<=m;++i)
    for(int j=0;j<=m;++j){
      t[v][min(i+j,m)]+=((t[v*2][i]%mod)*(t[v*2+1][j])%mod);
      t[v][min(i+j,m)]%=mod;
  }
}
void Build(int v,int i,int j){
    if(i==j){
        t[v][0]=b[i];
        t[v][1]=a[i];
        return;
    }
    int mid=(i+j)/2;
    Build(v*2,i,mid);
    Build(v*2+1,mid+1,j);
   update(v);
}
void UPD(int v,int i,int j,int pos){
    if(i==j){
        t[v][0]=b[i];
        t[v][1]=a[i];
        return;
    }
    int mid=(i+j)/2;
    if(pos<=mid)
        UPD(v*2,i,mid,pos);
    else
        UPD(v*2+1,mid+1,j,pos);
    update(v);
}
int main(){
scanf("%d%d",&n,&m);
for(int k=1;k<=n;k++){
 scanf("%d",&a[k]);
    a[k]%=mod;
}
for(int k=1;k<=n;k++){
 scanf("%d",&b[k]);
    b[k]%=mod;
}
Build(1,1,n);
cin>>Q;
while(Q--){
   int x,na,nb;
   scanf("%d%d%d",&x,&na,&nb);
   a[x]=na%mod;
   b[x]=nb%mod;
    UPD(1,1,n,x);
    int ans=t[1][m]%mod;
    printf("%d\n",ans);
}
return 0;
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:39:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d%d",&n,&m);
 ~~~~~^~~~~~~~~~~~~~
relativnost.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&a[k]);
  ~~~~~^~~~~~~~~~~~
relativnost.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&b[k]);
  ~~~~~^~~~~~~~~~~~
relativnost.cpp:52:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d%d",&x,&na,&nb);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 504 KB Output is correct
2 Correct 20 ms 504 KB Output is correct
3 Correct 38 ms 632 KB Output is correct
4 Correct 613 ms 12408 KB Output is correct
5 Correct 2115 ms 24220 KB Output is correct
6 Correct 3193 ms 24120 KB Output is correct
7 Correct 1385 ms 12664 KB Output is correct
8 Correct 714 ms 23796 KB Output is correct
9 Correct 1322 ms 24208 KB Output is correct
10 Execution timed out 4029 ms 24012 KB Time limit exceeded