제출 #869204

#제출 시각아이디문제언어결과실행 시간메모리
869204sleepntsheepBigger segments (IZhO19_segments)C++17
컴파일 에러
0 ms0 KiB
#include <stdio.h> #define N 500001 #pragma GCC target("avx2") #pragma GCC optimize("O3,unroll-loops") i,j,n,dp[N]; long long a[N], fw[N],x,c,p; u(p) { for (;p<N;p+=p&-p) fw[p]-=(fw[p]-x)*(x<fw[p]); } //long long q(p) { long long z=1e18;for(;p;p-=p&-p)z-=(z-fw[p])*(z>fw[p]); return z;} s(){ c=0,p=1e18; for(int j=(1<<19);j;j>>=1)if(c+j<=n&&(fw[j+c]<p?fw[j+c]:p)>x)c+=j,p=(fw[c]<p?fw[c]:p); return c+1; } main() { scanf("%d",&n);for(;++i<N;fw[i]=1e18); for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],x=2*a[i]-a[j],u(n-i+1); printf("%d",dp[n]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

segments.cpp:7:1: error: 'i' does not name a type
    7 | i,j,n,dp[N];
      | ^
segments.cpp:9:2: error: expected constructor, destructor, or type conversion before '(' token
    9 | u(p) { for (;p<N;p+=p&-p) fw[p]-=(fw[p]-x)*(x<fw[p]); }
      |  ^
segments.cpp:11:1: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
   11 | s(){
      | ^
segments.cpp: In function 'int s()':
segments.cpp:13:39: error: 'n' was not declared in this scope
   13 |     for(int j=(1<<19);j;j>>=1)if(c+j<=n&&(fw[j+c]<p?fw[j+c]:p)>x)c+=j,p=(fw[c]<p?fw[c]:p);
      |                                       ^
segments.cpp: At global scope:
segments.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main()
      | ^~~~
segments.cpp: In function 'int main()':
segments.cpp:18:17: error: 'n' was not declared in this scope
   18 |     scanf("%d",&n);for(;++i<N;fw[i]=1e18);
      |                 ^
segments.cpp:18:27: error: 'i' was not declared in this scope
   18 |     scanf("%d",&n);for(;++i<N;fw[i]=1e18);
      |                           ^
segments.cpp:19:10: error: 'i' was not declared in this scope
   19 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],x=2*a[i]-a[j],u(n-i+1);
      |          ^
segments.cpp:19:57: error: 'dp' was not declared in this scope; did you mean 'p'?
   19 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],x=2*a[i]-a[j],u(n-i+1);
      |                                                         ^~
      |                                                         p
segments.cpp:19:68: error: 'j' was not declared in this scope
   19 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],x=2*a[i]-a[j],u(n-i+1);
      |                                                                    ^
segments.cpp:19:105: error: 'u' was not declared in this scope
   19 |     for (i=1;i<=n;++i) scanf("%lld",a+i),x=a[i]+=a[i-1],dp[i]=1+dp[j=n+1-s(),j>0?j:(j=0)],x=2*a[i]-a[j],u(n-i+1);
      |                                                                                                         ^
segments.cpp:20:17: error: 'dp' was not declared in this scope; did you mean 'p'?
   20 |     printf("%d",dp[n]);
      |                 ^~
      |                 p