답안 #164332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164332 2019-11-19T12:02:51 Z beso123 Relativnost (COCI15_relativnost) C++14
0 / 140
243 ms 47784 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);
  for(int k=0;k<=m;k++)
    t[v][k]%=mod;
}
void Build(int v,int i,int j){
    if(i==j){
        t[v][0]=b[i]%mod;
        t[v][1]=a[i]%mod;
        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]%mod;
        t[v][1]=a[i]%mod;
        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(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
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:42: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:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&a[k]);
  ~~~~~^~~~~~~~~~~~
relativnost.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&b[k]);
  ~~~~~^~~~~~~~~~~~
relativnost.cpp:55: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);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Incorrect 3 ms 504 KB Output isn't correct
3 Incorrect 4 ms 504 KB Output isn't correct
4 Runtime error 68 ms 24184 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 167 ms 47736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 243 ms 47784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 106 ms 24512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 125 ms 47608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 119 ms 47608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 240 ms 47456 KB Execution killed with signal 11 (could be triggered by violating memory limits)