QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#467203#8008. Fortune Wheelljy_qojCompile Error//C++143.8kb2024-07-08 15:06:002024-07-08 15:06:01

Judging History

This is the latest submission verdict.

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-07-08 15:06:01]
  • Judged
  • [2024-07-08 15:06:00]
  • Submitted

answer

#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<chrono>
#include<climits>
#include<cmath>
#include<complex>
#include<condition_variable>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<mutex>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<random>
#include<regex>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<strstream>
#include<thread>
#include<type_traits>
#include<typeinfo>
#include<unordered_map>
#include<utility>
#include<vector>
#define int long long
using namespace std;

int n, x, k, z, m, now;
int a[510], stp[10010];
queue<int> q;

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> x >> k;
	for (int i = 1; i <= k; i++) {
		cin >> a[i];
		a[i] %= n;
	}
	for (int i = 1; i < n; i++) {
		stp[i] = LLONG_MAX;
	}
	q.push(0);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 1; i <= k; i++) {
			int v = (u - a[i] + n) % n;
			if (stp[v] == LLONG_MAX) {
				stp[v] = stp[u] + 1;
				q.push(v);
			}
		}
	}
	z = min(stp[x], n);
	m = 1;
	sort(stp + 1, stp + n + 1);
	for (int i = 1; i < n; i++) {
		if (stp[i] == LLONG_MAX) {
			break;
		}
		now += stp[i];
		now %= n;
		if ((now + n) * m < z * i) {
			z = now + n;
			m = i;
		}
	}
	int d = gcd(z, m);
	z /= d;
	m /= d;
	cout << z << ' ' << m;

	return 0;
}
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<chrono>
#include<climits>
#include<cmath>
#include<complex>
#include<condition_variable>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<mutex>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<random>
#include<regex>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<strstream>
#include<thread>
#include<type_traits>
#include<typeinfo>
#include<unordered_map>
#include<utility>
#include<vector>
#define int long long
using namespace std;

int n, x, k, z, m, now;
int a[510], stp[10010];
queue<int> q;

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> x >> k;
	for (int i = 1; i <= k; i++) {
		cin >> a[i];
		a[i] %= n;
	}
	for (int i = 1; i < n; i++) {
		stp[i] = LLONG_MAX;
	}
	q.push(0);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = 1; i <= k; i++) {
			int v = (u - a[i] + n) % n;
			if (stp[v] == LLONG_MAX) {
				stp[v] = stp[u] + 1;
				q.push(v);
			}
		}
	}
	z = min(stp[x], n);
	m = 1;
	sort(stp + 1, stp + n + 1);
	for (int i = 1; i < n; i++) {
		if (stp[i] == LLONG_MAX) {
			break;
		}
		now += stp[i];
		now %= n;
		if ((now + n) * m < z * i) {
			z = now + n;
			m = i;
		}
	}
	int d = gcd(z, m);
	z /= d;
	m /= d;
	cout << z << ' ' << m;

	return 0;
}

Details

In file included from /usr/include/c++/13/backward/strstream:50,
                 from answer.code:46:
/usr/include/c++/13/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
   32 | #warning \
      |  ^~~~~~~
answer.code:165:5: error: redefinition of ‘long long int n’
  165 | int n, x, k, z, m, now;
      |     ^
answer.code:56:5: note: ‘long long int n’ previously declared here
   56 | int n, x, k, z, m, now;
      |     ^
answer.code:165:8: error: redefinition of ‘long long int x’
  165 | int n, x, k, z, m, now;
      |        ^
answer.code:56:8: note: ‘long long int x’ previously declared here
   56 | int n, x, k, z, m, now;
      |        ^
answer.code:165:11: error: redefinition of ‘long long int k’
  165 | int n, x, k, z, m, now;
      |           ^
answer.code:56:11: note: ‘long long int k’ previously declared here
   56 | int n, x, k, z, m, now;
      |           ^
answer.code:165:14: error: redefinition of ‘long long int z’
  165 | int n, x, k, z, m, now;
      |              ^
answer.code:56:14: note: ‘long long int z’ previously declared here
   56 | int n, x, k, z, m, now;
      |              ^
answer.code:165:17: error: redefinition of ‘long long int m’
  165 | int n, x, k, z, m, now;
      |                 ^
answer.code:56:17: note: ‘long long int m’ previously declared here
   56 | int n, x, k, z, m, now;
      |                 ^
answer.code:165:20: error: redefinition of ‘long long int now’
  165 | int n, x, k, z, m, now;
      |                    ^~~
answer.code:56:20: note: ‘long long int now’ previously declared here
   56 | int n, x, k, z, m, now;
      |                    ^~~
answer.code:166:5: error: redefinition of ‘long long int a [510]’
  166 | int a[510], stp[10010];
      |     ^
answer.code:57:5: note: ‘long long int a [510]’ previously declared here
   57 | int a[510], stp[10010];
      |     ^
answer.code:166:13: error: redefinition of ‘long long int stp [10010]’
  166 | int a[510], stp[10010];
      |             ^~~
answer.code:57:13: note: ‘long long int stp [10010]’ previously declared here
   57 | int a[510], stp[10010];
      |             ^~~
answer.code:167:12: error: redefinition of ‘std::queue<long long int> q’
  167 | queue<int> q;
      |            ^
answer.code:58:12: note: ‘std::queue<long long int> q’ previously declared here
   58 | queue<int> q;
      |            ^
answer.code:169:5: error: redefinition of ‘long long int gcd(long long int, long long int)’
  169 | int gcd(int a, int b) {
      |     ^~~
answer.code:60:5: note: ‘long long int gcd(long long int, long long int)’ previously defined here
   60 | int gcd(int a, int b) {
      |     ^~~
answer.code:175:8: error: redefinition of ‘int main()’
  175 | signed main() {
      |        ^~~~
answer.code:66:8: note: ‘int main()’ previously defined here
   66 | signed main() {
      |        ^~~~