QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470220#6376. LaLa and Lamplichenyu_acWA 1ms4236kbC++14874b2024-07-10 11:21:022024-07-10 11:21:03

Judging History

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

  • [2024-07-10 11:21:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4236kb
  • [2024-07-10 11:21:02]
  • 提交

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];
void bfs(int s){
	memset(d,0x3f,sizeof(d));
	memset(v,0,sizeof(v));
	d[s]=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]>=1e9){
				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]),a[i]%=n;
	bfs(0);
	int ans=0,cnt=0;
	int up=min(d[S],n),down=1;
	sort(d+1,d+n+1);
	int sum=0;
	for(int i=1;i<n;i++){
		if(d[i]>=1e9)break;
		sum+=d[i];
		if((long long)up*i>(sum+n)*down){
			up=sum+n;
			down=i;
		}
	}
	int D=__gcd(up,down);
	printf("%d %d\n",up/D,down/D);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4236kb

input:

6
0
00
000
0110
00100
000000

output:

0 1

result:

wrong output format YES or NO expected, but 0 found