| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 944937 | sleepntsheep | Fancy Fence (CEOI20_fancyfence) | C11 | 23 ms | 6348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#define N 100002
#define M 1000000007ll
int n,h[N],w[N],l[N],r[N];
long long pw[N],z;
long long c2(long long x){return (x-1)*x%M*500000004ll%M;}
long long c(long long ww,long long hh)
{
ww%=M;
hh%=M;
return c2(ww+1)*c2(hh+1)%M;
}
void dfs(int u,int ll,int rr,int yy)
{
if(!u||ll>rr)return;
int y=h[u];
long long ww=(pw[rr]-pw[ll-1])%M;
z = (z + (c(ww,y) + M - c(ww,yy)) % M) % M;
dfs(l[u],ll,u-1,y);
dfs(r[u],u+1,rr,y);
}
int stk[N], top;
signed main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)scanf("%d",h+i);
for(int i=1;i<=n;++i)scanf("%d",w+i),pw[i]=pw[i-1]+w[i];
for(int i=1;i<=n;++i)
{
int k=top;
while(k&&h[stk[k]]>h[i])--k;
if(k)r[stk[k]]=i;
if(k<top)l[i]=stk[k+1];
stk[++k]=i;
top=k;
}
dfs(stk[1],1,n,0);
printf("%lld",z);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
