답안 #164320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164320 2019-11-19T11:36:55 Z beso123 Relativnost (COCI15_relativnost) C++14
0 / 140
2000 ms 65536 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,Q,a[100005],b[100005],t[400005][30],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]*t[v*2+1][j]);
  }
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);
}
main(){
cin>>n>>m;
for(int k=1;k<=n;k++)
    cin>>a[k];
for(int k=1;k<=n;k++)
    cin>>b[k];
Build(1,1,n);
cin>>Q;
while(Q--){
   int x,na,nb;
   cin>>x>>na>>nb;
   a[x]=na;
   b[x]=na;
    UPD(1,1,n,x);
    cout<<t[1][m]<<endl;
}
return 0;
}

Compilation message

relativnost.cpp:36:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 888 KB Output isn't correct
2 Incorrect 13 ms 888 KB Output isn't correct
3 Incorrect 16 ms 888 KB Output isn't correct
4 Runtime error 619 ms 34940 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
5 Runtime error 1184 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
6 Runtime error 1400 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
7 Runtime error 834 ms 35128 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
8 Runtime error 672 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
9 Runtime error 1042 ms 65536 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
10 Runtime error 2000 ms 57668 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)