QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#469685 | #8008. Fortune Wheel | SunsetLake | WA | 0ms | 3592kb | C++14 | 1.0kb | 2024-07-09 21:56:47 | 2024-07-09 21:56:47 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N = 1e5 + 5,M = 505,inf = 1e9 + 7;
int n,m,x,k[N];
int dis[N],id[N];
queue<int>q;
bool cmp(int i,int j){
return dis[i] < dis[j];
}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin >> n >> x >> m;
for(int i = 1;i <= m;++ i) cin >> k[i];
for(int i = 0;i <= n;++ i) dis[i] = inf;
dis[0] = 0;
q.push(0);
while(!q.empty()){
int u = q.front();
q.pop();
for(int i = 1;i <= m;++ i){
int v = (u + k[i]) % n;
if(dis[v] > dis[u] + 1){
dis[v] = dis[u] + 1;
q.push(v);
}
}
}
ll ap = inf,aq = 1;
if(dis[x] < inf) ap = dis[x];
for(int i = 0;i < n;++ i) id[i] = i;
sort(id,id + n,cmp);
ll sum = 0,sz = 0;
for(int i = 0;i < n;++ i){
if(dis[id[i]] == inf) break;
sum += dis[id[i]];sz ++;
ll nx = n + sum,ny = sz;
if(nx * aq < ny * ap)
aq = nx,ap = ny;
}
ll g = __gcd(aq,ap);
aq /= g;ap /= g;
cout << ap << " " << aq;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
6 3 2 2 4
output:
1 6
result:
wrong answer 1st numbers differ - expected: '8', found: '1'