QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#281462 | #2347. Traffic Blights | TadijaSebez | TL | 1934ms | 129948kb | C++14 | 2.0kb | 2023-12-10 06:09:47 | 2023-12-10 06:09:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ldb double
#define pb push_back
const int N=505;
const int M=101;
ldb ans[N];
int m[N],g[N],s[N];
const int X=2520;
bool good[X][N][M];
vector<pair<int,int>> best[X];
ldb Solve(int n){
ldb ans=0;
for(int ost=0;ost<X;ost++){
vector<pair<int,int>> all=best[ost];
for(int i=n;i<=n;i++){
int g=__gcd(X,m[i]);
int o=ost%g;
for(int j=0;j<m[i]/g;j++)good[ost][i][j]=false;
for(int j=0;j<::g[i];j++){
int x=(s[i]+j)%m[i];
if(x%g==o){
good[ost][i][x/g]=true;
}
}
all.pb({m[i]/g,i});
}
best[ost].clear();
sort(all.rbegin(),all.rend());
vector<bool> done(all.size(),false);
ldb now=1;
for(int i=0;i<all.size();i++){
if(!done[i]){
for(int j=i+1;j<all.size();j++){
if(all[i].first%all[j].first==0 && !done[j]){
int g1=m[all[i].second]/all[i].first;
int g2=m[all[j].second]/all[j].first;
int g3=__gcd(g1,g2);
int taken=0;
int val=ost%g1;
while(taken<all[i].first){
if(val%g2==ost%g2){
good[ost][all[i].second][val/g1%all[i].first]&=good[ost][all[j].second][val/g2%all[j].first];
taken++;
val+=g1*g2/g3;
}else{
val+=g1;
}
//val%=m[all[i].second];
}
//for(int z=0;z<all[i].first;z++){
// good[all[i].second][z]&=good[all[j].second][(z*g1+ost%g1)/g2%all[j].first];
//}
done[j]=true;
}
}
int cnt=0;
for(int j=0;j<all[i].first;j++){
cnt+=good[ost][all[i].second][j];
}
//printf("%i / %i\n",cnt,all[i].first);
now*=(ldb)cnt/all[i].first;
best[ost].pb(all[i]);
}
}
ans+=now;
}
return ans/X;
}
int main(){
int n;
scanf("%i",&n);
ans[0]=1;
for(int i=1;i<=n;i++){
int r,g,x;
scanf("%i %i %i",&x,&r,&g);
m[i]=r+g;
s[i]=((r-x)%m[i]+m[i])%m[i];
::g[i]=g;
ans[i]=Solve(i);
//printf("%.12f\n",ans[i]);
}
//printf("\n");
for(int i=1;i<=n+1;i++){
printf("%.12f\n",ans[i-1]-ans[i]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 127212kb
Test #2:
score: 0
Accepted
time: 3ms
memory: 127364kb
Test #3:
score: 0
Accepted
time: 4ms
memory: 126984kb
Test #4:
score: 0
Accepted
time: 3ms
memory: 128868kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 127324kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 127124kb
Test #7:
score: 0
Accepted
time: 3ms
memory: 127336kb
Test #8:
score: 0
Accepted
time: 3ms
memory: 127124kb
Test #9:
score: 0
Accepted
time: 4ms
memory: 129044kb
Test #10:
score: 0
Accepted
time: 4ms
memory: 127000kb
Test #11:
score: 0
Accepted
time: 4ms
memory: 129124kb
Test #12:
score: 0
Accepted
time: 12ms
memory: 127164kb
Test #13:
score: 0
Accepted
time: 23ms
memory: 129180kb
Test #14:
score: 0
Accepted
time: 28ms
memory: 129548kb
Test #15:
score: 0
Accepted
time: 11ms
memory: 127332kb
Test #16:
score: 0
Accepted
time: 44ms
memory: 127616kb
Test #17:
score: 0
Accepted
time: 59ms
memory: 127552kb
Test #18:
score: 0
Accepted
time: 63ms
memory: 127852kb
Test #19:
score: 0
Accepted
time: 48ms
memory: 127512kb
Test #20:
score: 0
Accepted
time: 24ms
memory: 129208kb
Test #21:
score: 0
Accepted
time: 11ms
memory: 127288kb
Test #22:
score: 0
Accepted
time: 296ms
memory: 129564kb
Test #23:
score: 0
Accepted
time: 16ms
memory: 127288kb
Test #24:
score: 0
Accepted
time: 332ms
memory: 129460kb
Test #25:
score: 0
Accepted
time: 11ms
memory: 127420kb
Test #26:
score: 0
Accepted
time: 232ms
memory: 129584kb
Test #27:
score: 0
Accepted
time: 15ms
memory: 127240kb
Test #28:
score: 0
Accepted
time: 376ms
memory: 129668kb
Test #29:
score: 0
Accepted
time: 1934ms
memory: 129868kb
Test #30:
score: 0
Accepted
time: 1405ms
memory: 129948kb
Test #31:
score: 0
Accepted
time: 202ms
memory: 129528kb
Test #32:
score: 0
Accepted
time: 210ms
memory: 129408kb
Test #33:
score: 0
Accepted
time: 183ms
memory: 129480kb
Test #34:
score: 0
Accepted
time: 572ms
memory: 129468kb
Test #35:
score: -100
Time Limit Exceeded