QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#844450 | #9220. Bus Analysis | zhenjianuo2025 | WA | 744ms | 17992kb | C++20 | 3.7kb | 2025-01-05 22:06:54 | 2025-01-05 22:06:55 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
bool Mbg;
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define inf (long long)(1e18)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
const int mod=1e9+7;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
void Dec(int &x,int y){x=x>=y?x-y:x-y+mod;}
int fpm(int x,int y){
int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}
int n,t[1010];
int f[2][77][77][77][2],g[2][77][77][77][2];
void Tr(int FR,int TO,int i,int a,int b,int c,int na,int nb,int nc,int v){
Add(g[i&1][na][nb][nc][TO],g[~i&1][a][b][c][FR]);
f[i&1][na][nb][nc][TO]=(f[i&1][na][nb][nc][TO]+f[~i&1][a][b][c][FR]+1ll*g[~i&1][a][b][c][FR]*v)%mod;
}
void work(){
cin>>n;
for(int i=1;i<=n;i++)cin>>t[i];
g[0][75][75][75][0]=1;
int ans=0;
for(int i=1;i<=n+1;i++){
memset(f[i&1],0,sizeof f[0]);
memset(g[i&1],0,sizeof g[0]);
for(int a=0;a<=75;a++){
for(int b=0;b<=75;b++){
for(int c=0;c<=75;c++){
if(f[~i&1][a][b][c][0]||g[~i&1][a][b][c][0]){
if(i==n+1){
Add(ans,f[n&1][a][b][c][0]);
}else{
Tr(0,0,i,a,b,c,min(75,a+t[i]-t[i-1]),min(75,b+t[i]-t[i-1]),min(75,c+t[i]-t[i-1]),0);
if(c+t[i]-t[i-1]<20){
Tr(0,0,i,a,b,c,min(75,a+t[i]-t[i-1]),min(75,b+t[i]-t[i-1]),min(75,c+t[i]-t[i-1]),0);
}else{
if(a+t[i]-t[i-1]<75){
Tr(0,1,i,a,b,c,75,75,20-(75-(a+t[i]-t[i-1])),0);
}else{
Tr(0,0,i,a,b,c,min(75,b+t[i]-t[i-1]),min(75,c+t[i]-t[i-1]),0,2);
}
}
}
}
if(f[~i&1][a][b][c][1]||g[~i&1][a][b][c][1]){
if(i==n+1){
Add(ans,f[n&1][a][b][c][1]);
}else{
Tr(1,1,i,a,b,c,75,75,min(75,c+t[i]-t[i-1]),0);
if(c+t[i]-t[i-1]<20){
Tr(1,1,i,a,b,c,75,75,c+t[i]-t[i-1],0);
}else{
Tr(1,0,i,a,b,c,75,75,0,2);
}
}
}
}
}
}
}
cout<<ans<<'\n';
}
bool Med;
signed main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int T=1;while(T--)work();
// cerr<<"Time: "<<clock()<<" ms;\n";
// cerr<<"Memory: "<<abs(&Med-&Mbg)/1024.0/1024.0<<" MiB.\n";
}
/*
- CONTINUE, NON-STOPPING, FOR THE FAITH
- START TYPING IF YOU DON'T KNOW WHAT TO DO
- STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 17992kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 3ms
memory: 17860kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 744ms
memory: 17924kb
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'