QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#281463#2347. Traffic BlightsTadijaSebezTL 361ms23872kbC++142.1kb2023-12-10 06:11:372023-12-10 06:11:39

Judging History

This is the latest submission verdict.

  • [2023-12-10 06:11:39]
  • Judged
  • Verdict: TL
  • Time: 361ms
  • Memory: 23872kb
  • [2023-12-10 06:11:37]
  • Submitted

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[X][N];
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]=1;
				}
			}
			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[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: 3ms
memory: 21080kb

Test #2:

score: 0
Accepted
time: 0ms
memory: 22128kb

Test #3:

score: 0
Accepted
time: 0ms
memory: 23048kb

Test #4:

score: 0
Accepted
time: 1ms
memory: 3832kb

Test #5:

score: 0
Accepted
time: 0ms
memory: 22092kb

Test #6:

score: 0
Accepted
time: 3ms
memory: 18048kb

Test #7:

score: 0
Accepted
time: 0ms
memory: 23048kb

Test #8:

score: 0
Accepted
time: 3ms
memory: 22060kb

Test #9:

score: 0
Accepted
time: 0ms
memory: 21980kb

Test #10:

score: 0
Accepted
time: 7ms
memory: 15004kb

Test #11:

score: 0
Accepted
time: 3ms
memory: 20188kb

Test #12:

score: 0
Accepted
time: 12ms
memory: 23156kb

Test #13:

score: 0
Accepted
time: 25ms
memory: 23296kb

Test #14:

score: 0
Accepted
time: 29ms
memory: 22544kb

Test #15:

score: 0
Accepted
time: 12ms
memory: 23188kb

Test #16:

score: 0
Accepted
time: 45ms
memory: 23396kb

Test #17:

score: 0
Accepted
time: 64ms
memory: 15576kb

Test #18:

score: 0
Accepted
time: 66ms
memory: 20904kb

Test #19:

score: 0
Accepted
time: 55ms
memory: 19848kb

Test #20:

score: 0
Accepted
time: 27ms
memory: 22492kb

Test #21:

score: 0
Accepted
time: 11ms
memory: 22168kb

Test #22:

score: 0
Accepted
time: 275ms
memory: 23724kb

Test #23:

score: 0
Accepted
time: 17ms
memory: 23100kb

Test #24:

score: 0
Accepted
time: 326ms
memory: 23764kb

Test #25:

score: 0
Accepted
time: 8ms
memory: 22132kb

Test #26:

score: 0
Accepted
time: 209ms
memory: 23768kb

Test #27:

score: 0
Accepted
time: 9ms
memory: 23212kb

Test #28:

score: 0
Accepted
time: 361ms
memory: 23872kb

Test #29:

score: -100
Time Limit Exceeded