QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#281464 | #2347. Traffic Blights | TadijaSebez | TL | 407ms | 4128kb | C++14 | 2.1kb | 2023-12-10 06:14:45 | 2023-12-10 06:14:46 |
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;
bitset<M> good[N];
vector<pair<int,int>> best;
void Solve(int ost, int n){
vector<pair<int,int>> all=best;
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[i][j]=0;
for(int j=0;j<::g[i];j++){
int x=(s[i]+j)%m[i];
if(x%g==o){
good[i][x/g]=1;
}
}
all.pb({m[i]/g,i});
}
best.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[all[i].second][val/g1%all[i].first]=good[all[i].second][val/g1%all[i].first]&good[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[all[i].second][j];
}
//printf("%i / %i\n",cnt,all[i].first);
now*=(ldb)cnt/all[i].first;
best.pb(all[i]);
}
}
ans[n]+=now;
}
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;
//printf("%.12f\n",ans[i]);
}
for(int ost=0;ost<X;ost++){
best.clear();
for(int i=1;i<=n;i++){
Solve(ost,i);
}
}
for(int i=1;i<=n;i++){
ans[i]/=X;
}
//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: 1ms
memory: 3812kb
Test #2:
score: 0
Accepted
time: 2ms
memory: 3828kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 4128kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3744kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 4116kb
Test #6:
score: 0
Accepted
time: 2ms
memory: 3972kb
Test #7:
score: 0
Accepted
time: 2ms
memory: 3876kb
Test #8:
score: 0
Accepted
time: 2ms
memory: 4104kb
Test #9:
score: 0
Accepted
time: 1ms
memory: 3804kb
Test #10:
score: 0
Accepted
time: 4ms
memory: 3828kb
Test #11:
score: 0
Accepted
time: 3ms
memory: 3876kb
Test #12:
score: 0
Accepted
time: 14ms
memory: 3768kb
Test #13:
score: 0
Accepted
time: 22ms
memory: 3816kb
Test #14:
score: 0
Accepted
time: 30ms
memory: 3872kb
Test #15:
score: 0
Accepted
time: 10ms
memory: 3812kb
Test #16:
score: 0
Accepted
time: 46ms
memory: 3812kb
Test #17:
score: 0
Accepted
time: 66ms
memory: 3912kb
Test #18:
score: 0
Accepted
time: 62ms
memory: 3820kb
Test #19:
score: 0
Accepted
time: 59ms
memory: 3828kb
Test #20:
score: 0
Accepted
time: 28ms
memory: 4104kb
Test #21:
score: 0
Accepted
time: 12ms
memory: 4100kb
Test #22:
score: 0
Accepted
time: 299ms
memory: 3824kb
Test #23:
score: 0
Accepted
time: 14ms
memory: 3800kb
Test #24:
score: 0
Accepted
time: 348ms
memory: 3880kb
Test #25:
score: 0
Accepted
time: 5ms
memory: 3936kb
Test #26:
score: 0
Accepted
time: 232ms
memory: 3832kb
Test #27:
score: 0
Accepted
time: 13ms
memory: 3804kb
Test #28:
score: 0
Accepted
time: 407ms
memory: 4124kb
Test #29:
score: -100
Time Limit Exceeded