QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470139#8008. Fortune Wheelc20251515WA 1ms4636kbC++20925b2024-07-10 10:47:442024-07-10 10:47:45

Judging History

你现在查看的是最新测评结果

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 10:47:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4636kb
  • [2024-07-10 10:47:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll n,x,m,k[N],ans=0;
ll dis[N];
ll sum=0,p=0,q=0;
void bfs(){
	queue<ll> q;
	memset(dis,inf,sizeof(dis));
	dis[0]=0;
	q.push(0);
	while(!q.empty()){
		ll u=q.front();
		q.pop();
		for(int i=1;i<=m;i++){
			ll v=(u-k[i]+n)%n;
			if(dis[v]==inf){
				dis[v]=dis[u]+1;
				q.push(v);
			}
		}
	}
}
int main(){
	cin>>n>>x>>m;
	for(int i=1;i<=m;i++) cin>>k[i];
	bfs();
	sort(dis,dis+n);
	p=dis[x];
	q=1;
	for(int i=0;i<n;i++){
		if(dis[i]==inf) continue;
		/*
		最优策略要么先随机转动,再转动固定路径,要么直接可以转动固定路径 
		若从x随机转动跳到的点y,dis[y]>dis[x],则肯定不优,否则可以跳 
		*/
		sum+=dis[i];
		if((sum+n)*q<(i+1)*p){
			p=sum+n;
			q=i+1;
		}
	}
	cout<<p/__gcd(p,q)<<" "<<q/__gcd(p,q);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4328kb

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4636kb

input:

5 4 1
1

output:

8 3

result:

wrong answer 1st numbers differ - expected: '1', found: '8'