QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#573027 | #9220. Bus Analysis | -xcxxx- | WA | 4ms | 10384kb | C++14 | 1.8kb | 2024-09-18 17:06:49 | 2024-09-18 17:06:50 |
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-1]<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]={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]>=t[i]-74;x++) for(int y=0;y<=i&&t[i-y]>=t[i]-74;y++) for(int z=0;z<=i&&t[i-z]>=t[i]-74;z++) if(dp[0][x][y][z].cnt) {
int xx=add(x,i),yy=add(y,i),zz=add(z,i);
dp[1][xx][yy][zz]+=dp[0][x][y][z];
int val=1;
if(z&&t[i+1]-t[i-z]<=75) val=0;
if(x&&t[i+1]-t[i-x]<=20) val=0;
printf("i=%d x=%d y=%d z=%d val=%d\n",i,x,y,z,val);
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=1;x<=i&&t[i-x]>=t[i]-74;x++) for(int y=0;y<=i&&t[i-y]>=t[i]-74;y++) for(int z=0;z<=i&&t[i-z]>=t[i]-74;z++)
fprintf(stderr,"dp[%d][%d][%d][%d]=(%d,%d)\n",i,x,y,z,dp[0][x][y][z].cnt,dp[i&1][x][y][z].sum);
}
int ans=0;
for(int x=1;x<=n&&t[n-x]>=t[n]-74;x++) for(int y=0;y<=n&&t[n-y]>=t[n]-74;y++) for(int z=0;z<=n&&t[n-z]>=t[n]-74;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: 4ms
memory: 10384kb
input:
3 1 8 20
output:
i=0 x=0 y=0 z=0 val=1 i=1 x=0 y=0 z=0 val=1 i=1 x=1 y=0 z=0 val=0 i=2 x=0 y=0 z=0 val=1 i=2 x=1 y=0 z=0 val=0 i=2 x=2 y=0 z=0 val=0 14
result:
wrong output format Expected integer, but "i=0" found