QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#530033 | #9220. Bus Analysis | ucup-team1004# | WA | 11ms | 67500kb | C++14 | 2.1kb | 2024-08-24 14:41:46 | 2024-08-24 14:41:46 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1000+5,M=N*2+5,K=1e7+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,A[N];
ll f[N][16][16][16],g[N][16][16][16];
ll pw[N];
void Solve(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&A[i]);
for(int i=pw[0]=1;i<=n;i++) pw[i]=pw[i-1]*2%mod;
A[n+1]=A[n]+100;
f[1][15][15][15]=0;g[1][15][15][15]=1;
for(int i=1;i<=n;i++){
for(int x=0;x<=15;x++) for(int y=0;y<=15;y++) for(int z=0;z<=15;z++) if(g[i][x][y][z]||f[i][x][y][z]){
(f[i+1][x][y][min(15,z+A[i+1]-A[i])]+=f[i][x][y][z])%=mod;
(g[i+1][x][y][min(15,z+A[i+1]-A[i])]+=g[i][x][y][z])%=mod;
if(x+y+z<15){
int pt=i;while(A[pt+1]-A[i]<15-x-y-z) pt++;
(f[pt+1][15][15][15]+=f[i][x][y][z]*pw[pt-i])%=mod;
(g[pt+1][15][15][15]+=g[i][x][y][z]*pw[pt-i])%=mod;
}else{
int pt=i;while(A[pt+1]-A[i]<20) pt++;
(f[pt+1][y][z][min(A[pt+1]-A[i]-20,15)]+=(f[i][x][y][z]+g[i][x][y][z])*pw[pt-i])%=mod;
(g[pt+1][y][z][min(A[pt+1]-A[i]-20,15)]+=g[i][x][y][z]*pw[pt-i])%=mod;
}
}
}
ll tot=0;
for(int x=0;x<=15;x++) for(int y=0;y<=15;y++) for(int z=0;z<=15;z++) tot+=f[n+1][x][y][z];
printf("%lld\n",tot%mod*2%mod);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 6124kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 0ms
memory: 6108kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 11ms
memory: 67500kb
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:
259619098
result:
wrong answer 1st numbers differ - expected: '932594593', found: '259619098'