QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469917#8008. Fortune WheelqLWA 113ms58508kbC++141017b2024-07-10 08:56:432024-07-10 08:56:43

Judging History

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

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

answer

#include <algorithm>
#include <cstdio>
#include <vector>
using i32 = int;
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("%d%d%d", &n, &arrow, &m);
	for (i32 i = 0, x, p; i < m; ++i)
		for (scanf("%d", &x), p = 0; p < n; ++p) G[(p + x) % n].emplace_back(p);
	static i32 que[N], *hd, *tl;
	__builtin_memset(dep, -1, sizeof(dep));
	dep[*(hd = tl = que) = 0] = 0;
	for (i32 u; hd <= tl;)
		for (i32 v : G[u = que[*hd++]])
			if (!~dep[v]) dep[*++tl = v] = dep[u] + 1;
	i64 ansx = ~dep[arrow] ? dep[arrow] : 0x3f3f3f3f, ansy = 1, sum = 0;
	std::sort(dep, dep + n), std::reverse(dep, dep + n);
	for (i32 i = 1; i <= n; ++i) {
		if (!~dep[i - 1]) 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6536kb

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

score: 0
Accepted
time: 2ms
memory: 6516kb

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: -100
Wrong Answer
time: 113ms
memory: 58508kb

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'