QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#821631 | #9220. Bus Analysis | like_AC | WA | 103ms | 72852kb | C++14 | 2.4kb | 2024-12-19 17:00:49 | 2024-12-19 17:00:50 |
Judging History
answer
#include <bits/stdc++.h>
#define add(x,y) x=((x)+(y))%mod
#define ll long long
using namespace std;
const int N=1010;
const ll mod=1e9+7;
ll f[N][80][80],g[N][80][80];
ll poww[N];
int n,pos[N];
ll pf[N],pg[N];
void work()
{
poww[0]=1;
for(int i=1;i<N;++i)
{
poww[i]=poww[i-1]*2%mod;
}
for(int i=0;i<N;++i)
{
poww[i]=(poww[i]-1+mod)%mod;
}
/*f[1][1][75]=1;
g[1][1][75]=1;
f[1][75][75]=1;
g[1][75][75]=0;*/
ll sumf=1,sumg=0;
for(int i=1;i<=n;++i)
{
sumf+=pf[i];
sumg+=pg[i];
sumf%=mod;
sumg%=mod;
int nxti=lower_bound(pos+1,pos+n+1,pos[i]+20)-pos-1;
add(f[nxti][pos[nxti]-pos[i]+1][75],sumf*(poww[nxti-i]+1));
add(g[nxti][pos[nxti]-pos[i]+1][75],(sumg+sumf)*(poww[nxti-i]+1));
/*if(i==n)
continue ;*/
for(int x=0;x<=75;++x)
{
for(int y=0;y<=75;++y)
{
int j=lower_bound(pos+1,pos+n+1,max(pos[i]+20,max(pos[i]-x+40,pos[i]-y+75)))-pos-1;
/*if(f[i][x][y])
{
cout<<i<<" "<<x<<" "<<y<<" "<<f[i][x][y]<<" "<<g[i][x][y]<<' '<<j<<'\n';
}*/
if(i==n)
continue ;
if(j==i)
{
// i+1 不选
/*add(f[i+1][min(x+pos[i+1]-pos[i],75)][min(y+pos[i+1]-pos[i],75)],f[i][x][y]);
add(g[i+1][min(x+pos[i+1]-pos[i],75)][min(y+pos[i+1]-pos[i],75)],g[i][x][y]);
// i+1 选
add(f[i+1][min(pos[i+1]-pos[i],75)][min(x+pos[i+1]-pos[i],75)],f[i][x][y]);
add(g[i+1][min(pos[i+1]-pos[i],75)][min(x+pos[i+1]-pos[i],75)],g[i][x][y]+f[i][x][y]); */
add(sumf,f[i][x][y]);
add(sumg,g[i][x][y]);
continue ;
}
//(i,j]内不选
//add(f[j][min(x+pos[j]-pos[i],75)][min(y+pos[j]-pos[i],75)],f[i][x][y]);
//add(g[j][min(x+pos[j]-pos[i],75)][min(y+pos[j]-pos[i],75)],g[i][x][y]);
add(pf[j+1],f[i][x][y]);
add(pg[j+1],g[i][x][y]);
//(i,j]内选
add(f[j][min(pos[j]-pos[i],75)][min(x+pos[j]-pos[i],75)],f[i][x][y]*poww[j-i]);
add(g[j][min(pos[j]-pos[i],75)][min(x+pos[j]-pos[i],75)],(g[i][x][y]+f[i][x][y])*poww[j-i]);
}
}
}
add(sumf,pf[n+1]);
add(sumg,pg[n+1]);
//cout<<sumf<<" "<<sumg<<'\n';
ll ans=0;
for(int i=0;i<=75;++i)
{
for(int j=0;j<=75;++j)
{
/*if(f[n][i][j])
{
cout<<i<<" "<<j<<" "<<f[n][i][j]<<" "<<g[n][i][j]<<'\n';
}*/
add(ans,g[n][i][j]);
}
}
add(ans,sumg);
printf("%lld\n",ans*2%mod);
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d",&pos[i]);
}
work();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3896kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3996kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 103ms
memory: 72852kb
input:
1000 2 7 9 12 14 17 18 21 22 28 29 33 34 35 37 38 44 45 46 50 58 59 63 66 71 72 75 76 77 78 80 81 83 84 87 92 100 101 107 108 109 112 114 116 118 123 124 131 142 143 144 145 148 150 151 152 153 155 157 158 165 167 168 169 171 176 182 185 190 192 198 202 204 205 212 213 223 224 225 226 229 231 240 24...
output:
43597068
result:
wrong answer 1st numbers differ - expected: '932594593', found: '43597068'