QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470214#8008. Fortune Wheellichenyu_acRE 0ms0kbC++14884b2024-07-10 11:18:532024-07-10 11:18:53

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 11:18:53]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-10 11:18:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;

int s,t;
int n,m,a[N];

bool v[N];
int d[N];
int bfs(int s){
	memset(d,0x3f,sizeof(d));
	memset(v,0,sizeof(v));
	d[0]=0;
	queue<int>q;
	q.push(s);
	while(q.size()){
		int x=q.front();q.pop();
		if(v[x])continue;
		v[x]=1;
		for(int i=1;i<=m;i++){
			int y=((x-a[i]+n)%n+n)%n;
			if(d[y]>d[x]+1){
				d[y]=d[x]+1;
				q.push(y);
			}
		}
	}
}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

int main(){
	scanf("%d%d%d",&n,&s,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	int ans=0,cnt=0;
	bfs(0);
	for(int i=0;i<n;i++){
		if(d[i]==0x3f3f3f3f)continue;
		ans+=d[i];
//		printf("%d %d\n",i,dist);
		cnt++;
	}
	ans+=n;
	int D=gcd(ans,cnt);
	ans/=D,cnt/=D;
	int dist=d[s];
	if((long long)dist*cnt<ans)printf("%d 1\n",dist);
	else printf("%d %d\n",ans,cnt);
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

6 3 2
2 4

output:


result: