QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#573880 | #9220. Bus Analysis | -xcxxx- | WA | 0ms | 10464kb | C++14 | 1.9kb | 2024-09-18 20:10:18 | 2024-09-18 20:10:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int rd() {int x=0,f=1;char c=getchar();while(!isdigit(c))f=(c=='-'?-1:f),c=getchar();while(isdigit(c))x=x*10+c-'0',c=getchar();return x*f;}
const int N=1005,mod=1e9+7;
int n,t[N];
struct state {int cnt,sum;}dp[2][75][75][75];
state add(state a) {
(a.sum+=a.cnt)%=mod;
return a;
}
state operator+(state a,state b) {
(a.cnt+=b.cnt)%=mod;
(a.sum+=b.cnt)%=mod;
return a;
}
state operator+=(state &a,state b) {return a=a+b;}
int add(int a,int i) {
if(a==0) return 0;
if(t[i-a]<t[i]-74) return 0;
return a+1;
}
signed main() {
n=rd();
for(int i=1;i<=n;i++) t[i]=rd();
dp[1][0][0][0]=(state){1,0};
for(int i=0;i<n;i++) {
memcpy(dp[0],dp[1],sizeof(dp[0]));
memset(dp[1],0,sizeof(dp[1]));
for(int x=0;x<=i&&t[i-x+1]>=t[i]-74;x++) for(int y=0;y<=i&&t[i-y+1]>=t[i]-74;y++) for(int z=0;z<=i&&t[i-z+1]>=t[i]-74;z++) if(dp[0][x][y][z].cnt) {
int xx=add(x,i+1),yy=add(y,i+1),zz=add(z,i+1);
dp[1][xx][yy][zz]+=dp[0][x][y][z];
int val=1;
if(z&&t[i+1]-t[i-z+1]<75) val=0;
if(x&&t[i+1]-t[i-x+1]<20) val=0;
printf("i=%d x=%d y=%d z=%d val=%d xx=%d yy=%d zz=%d\n",i,x,y,z,val,xx,yy,zz);
if(val) dp[1][1][xx][yy]+=add(dp[0][x][y][z]);
else dp[1][xx][yy][zz]+=dp[0][x][y][z];
}
for(int x=0;x<=i&&t[i-x+1]>=t[i]-74;x++) for(int y=0;y<=i&&t[i-y+1]>=t[i]-74;y++) for(int z=0;z<=i&&t[i-z+1]>=t[i]-74;z++) if(dp[1][x][y][z].cnt)
fprintf(stderr,"dp[%d][%d][%d][%d]=(%d,%d)\n",i+1,x,y,z,dp[1][x][y][z].cnt,dp[1][x][y][z].sum);
}
int ans=0;
for(int x=0;!x||x<=n&&t[n-x+1]>=t[n]-74;x++) for(int y=0;!y||y<=n&&t[n-y+1]>=t[n]-74;y++) for(int z=0;!z||z<=n&&t[n-z+1]>=t[n]-7474;z++) (ans+=dp[1][x][y][z].sum)%=mod;
printf("%d\n",ans*2);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 10464kb
input:
3 1 8 20
output:
i=0 x=0 y=0 z=0 val=1 xx=0 yy=0 zz=0 i=1 x=0 y=0 z=0 val=1 xx=0 yy=0 zz=0 i=1 x=1 y=0 z=0 val=0 xx=2 yy=0 zz=0 i=2 x=0 y=0 z=0 val=1 xx=0 yy=0 zz=0 i=2 x=1 y=0 z=0 val=0 xx=2 yy=0 zz=0 i=2 x=2 y=0 z=0 val=0 xx=3 yy=0 zz=0 16
result:
wrong output format Expected integer, but "i=0" found