QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#469924#8008. Fortune WheelqLWA 96ms109172kbC++141014b2024-07-10 09:01:092024-07-10 09:01:10

Judging History

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

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

answer

#include <algorithm>
#include <cstdio>
#include <vector>
// using i32 = int;
#define i32 i64
using i64 = long long;
constexpr i32 N = 1E5, M = 500;
i32 n, arrow, m;
std::vector<i32> G[N];
i32 dep[N];
i64 gcd(i64 a, i64 b) noexcept { return b ? gcd(b, a % b) : a; }
signed main() noexcept {
	scanf("%lld%lld%lld", &n, &arrow, &m);
	for (i32 i = 0, x, p; i < m; ++i)
		for (scanf("%lld", &x), p = 0; p < n; ++p) G[(p + x) % n].emplace_back(p);
	static i32 que[N], *hd, *tl;
	__builtin_memset(dep, 0x3f, sizeof(dep));
	dep[*(hd = tl = que) = 0] = 0;
	for (i32 u; hd <= tl;)
		for (i32 v : G[u = que[*hd++]])
			if (dep[v] == 0x3f3f3f3f3f3f3f3f) dep[*++tl = v] = dep[u] + 1;
	i64 ansx = dep[arrow], ansy = 1, sum = 0;
	std::sort(dep, dep + n);
	for (i32 i = 1; i <= n; ++i) {
		if (dep[i - 1] > n) break;
		sum += dep[i - 1];
		i64 x = n + sum, y = i;
		if (x * ansy < ansx * y) ansx = x, ansy = y;
	}
	i64 g = gcd(ansx, ansy);
	printf("%lld %lld\n", ansx /= g, ansy /= g);
	return 0;
}

詳細信息

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7344kb

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: -100
Wrong Answer
time: 96ms
memory: 109172kb

input:

99999 65238 100
64714 45675 36156 13116 93455 22785 10977 60219 14981 25839 83709 80404 41400 12469 31530 65521 35436 20326 96792 50699 27522 98233 26187 12509 90992 72693 83919 74145 80892 68422 38333 33497 89154 88403 77492 4570 3908 59194 3482 89871 96330 45114 5555 73987 95832 476 949 74649 2084...

output:

100099 101

result:

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