QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#841595 | #9220. Bus Analysis | zhenjianuo2025 | WA | 145ms | 48908kb | C++20 | 3.2kb | 2025-01-03 20:54:44 | 2025-01-03 20:54:44 |
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 int 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];
map<int,map<int,int> > f[1010][2],g[1010][2];
void Add(int FR,int TO,int i,int a,int b,int na,int nb,int c){
Add(g[i][TO][na][nb],g[i-1][FR][a][b]);
(f[i][TO][na][nb]+=f[i-1][FR][a][b]+c*g[i-1][FR][a][b])%=mod;
}
void work(){
cin>>n;
for(int i=1;i<=n;i++)cin>>t[i];
g[0][0][56][56]=1;
int ans=0;
for(int i=1;i<=n+1;i++){
for(auto T1:g[i-1][0]){
int a=T1.x;
for(auto T2:T1.y){
int b=T2.x;
if(i==n+1){
Add(ans,f[n][0][a][b]);
continue;
}
Add(0,0,i,a,b,min(56ll,a+t[i]-t[i-1]),min(56ll,b+t[i]-t[i-1]),0);
if(b+t[i]-t[i-1]<20){
Add(0,0,i,a,b,min(56ll,a+t[i]-t[i-1]),b+t[i]-t[i-1],0);
}else{
if(a+t[i]-t[i-1]<=55){
Add(0,1,i,a,b,56,(a+t[i]-t[i-1])-75,2);
}else{
Add(0,0,i,a,b,min(b+t[i]-t[i-1],56ll),0,2);
}
}
}
}
for(auto T1:g[i-1][1]){
int a=T1.x;
for(auto T2:T1.y){
int b=T2.x;
if(i==n+1){
Add(ans,f[n][1][a][b]);
continue;
}
Add(1,1,i,a,b,min(56ll,a+t[i]-t[i-1]),min(56ll,b+t[i]-t[i-1]),0);
if(b+t[i]-t[i-1]<20){
Add(1,1,i,a,b,min(56ll,a+t[i]-t[i-1]),b+t[i]-t[i-1],0);
}else{
Add(1,0,i,a,b,min(b+t[i]-t[i-1],56ll),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: 1ms
memory: 3856kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 145ms
memory: 48908kb
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:
856529254
result:
wrong answer 1st numbers differ - expected: '932594593', found: '856529254'