QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470220 | #6376. LaLa and Lamp | lichenyu_ac | WA | 1ms | 4236kb | C++14 | 874b | 2024-07-10 11:21:02 | 2024-07-10 11:21:03 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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