답안 #164322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164322 2019-11-19T11:46:47 Z beso123 Relativnost (COCI15_relativnost) C++14
0 / 140
325 ms 53108 KB
#include <bits/stdc++.h>
#define int long long
#define mod 10007
using namespace std;
int n,m,Q,a[100005],b[100005],t[200005][21],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;
  }
  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);
}
main(){
scanf("%I64d%I64d",&n,&m);
for(int k=1;k<=n;k++){
 scanf("%I64d",&a[k]);
    a[k]%=mod;
}
for(int k=1;k<=n;k++){
 scanf("%I64d",&b[k]);
    b[k]%=mod;
}
Build(1,1,n);
cin>>Q;
while(Q--){
   int x,na,nb;
   scanf("%I64d%I64d%I64d",&x,&na,&nb);
   a[x]=na%mod;
   b[x]=nb%mod;
    UPD(1,1,n,x);
    int ans=t[1][m]%mod;
    printf("%I64d\n",ans);
}
return 0;
}

Compilation message

relativnost.cpp:41:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
relativnost.cpp: In function 'int main()':
relativnost.cpp:42:25: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 scanf("%I64d%I64d",&n,&m);
                    ~~   ^
relativnost.cpp:42:25: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
relativnost.cpp:44:21: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  scanf("%I64d",&a[k]);
                ~~~~~^
relativnost.cpp:48:21: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  scanf("%I64d",&b[k]);
                ~~~~~^
relativnost.cpp:55:38: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
    scanf("%I64d%I64d%I64d",&x,&na,&nb);
                            ~~        ^
relativnost.cpp:55:38: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
relativnost.cpp:55:38: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
relativnost.cpp:60:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
     printf("%I64d\n",ans);
                         ^
relativnost.cpp:42:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%I64d%I64d",&n,&m);
 ~~~~~^~~~~~~~~~~~~~~~~~~~
relativnost.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%I64d",&a[k]);
  ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%I64d",&b[k]);
  ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:55:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%I64d%I64d%I64d",&x,&na,&nb);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 7 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 155 ms 45744 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 257 ms 53108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 325 ms 52856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 215 ms 46200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 223 ms 52860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 199 ms 52984 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 283 ms 48504 KB Execution killed with signal 11 (could be triggered by violating memory limits)