QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#574279 | #9220. Bus Analysis | -xcxxx- | RE | 329ms | 10496kb | C++14 | 1.9kb | 2024-09-18 21:22:07 | 2024-09-18 21:22:13 |
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.sum)%=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]-t[i-a]>=75) 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]-t[i-x+1]<75;x++) for(int y=0;y<=i&&t[i]-t[i-y+1]<75;y++) for(int z=0;z<=i&&t[i]-t[i-z+1]<75;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]-t[n-x+1]<75;x++) for(int y=0;!y||y<=n&&t[n]-t[n-y+1]<75;y++) for(int z=0;!z||z<=n&&t[n]-t[n-z+1]<75;z++) (ans+=dp[1][x][y][z].sum)%=mod;
printf("%d\n",ans*2%mod);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 10380kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 0ms
memory: 10372kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: 0
Accepted
time: 329ms
memory: 10376kb
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:
932594593
result:
ok 1 number(s): "932594593"
Test #4:
score: 0
Accepted
time: 77ms
memory: 10420kb
input:
200 1 2 4 9 10 11 12 15 16 17 18 19 22 24 27 28 33 36 37 39 43 44 45 47 48 49 50 51 52 56 60 61 62 63 68 70 71 72 73 74 78 80 81 84 86 92 93 98 99 100 102 105 107 108 110 111 114 115 116 122 123 125 129 132 133 135 137 138 139 141 142 143 144 149 150 151 152 153 154 155 159 160 165 171 172 174 176 1...
output:
422301620
result:
ok 1 number(s): "422301620"
Test #5:
score: 0
Accepted
time: 313ms
memory: 10324kb
input:
1000 999975020 999975030 999975050 999975056 999975085 999975118 999975207 999975213 999975240 999975307 999975332 999975344 999975356 999975384 999975405 999975468 999975499 999975558 999975559 999975571 999975631 999975664 999975680 999975689 999975731 999975738 999975765 999975831 999975838 99997...
output:
335758758
result:
ok 1 number(s): "335758758"
Test #6:
score: 0
Accepted
time: 0ms
memory: 10384kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #7:
score: 0
Accepted
time: 318ms
memory: 10376kb
input:
1000 214 216 381 497 539 645 772 927 1211 1238 1239 1298 1403 1426 1437 1504 1515 1648 1800 1816 1946 2008 2038 2066 2144 2173 2236 2253 2291 2574 2632 2643 2658 2671 2689 2886 2910 2948 3002 3033 3039 3057 3077 3188 3240 3322 3331 3449 3467 3578 3730 3796 3897 3973 4152 4160 4199 4331 4386 4429 465...
output:
877690181
result:
ok 1 number(s): "877690181"
Test #8:
score: 0
Accepted
time: 3ms
memory: 10496kb
input:
1 963837006
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 311ms
memory: 10496kb
input:
999 17 234 337 379 449 607 646 703 716 878 887 898 901 942 964 1075 1198 1356 1432 1546 1547 1619 1668 1769 1818 1826 1881 1900 1960 2017 2088 2266 2273 2339 2376 2377 2396 2399 2438 2461 2484 2567 2620 2661 2680 2791 2881 3040 3081 3082 3094 3102 3205 3218 3225 3227 3239 3250 3331 3393 3425 3530 35...
output:
651884156
result:
ok 1 number(s): "651884156"
Test #10:
score: -100
Runtime Error
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...