QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#543875#27. The Battle for Wesnoth5un_xiaomivita_msgCompile Error//C++982.4kb2024-09-01 22:56:022024-09-01 22:56:03

Judging History

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

  • [2024-09-01 22:56:03]
  • 评测
  • [2024-09-01 22:56:02]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#include <bits/stdc++.h>
const double eps = 1e-6;
template <int T>
struct fast_io {
	char p[T], *p1, *p2, q[T], *q1, *q2;
	fast_io() {
		p1 = p2 = p, q1 = q, q2 = q + T;
		fread(p, 1, T, stdin);	
	}
	char gc() {
		return *p1++;
	}
	void pc(char ch) {
		*q1++ = ch;
	}
	~fast_io() {
		fwrite(q, 1, q1 - q, stdout);	
	}
};
fast_io<1 << 21> io;
int read() {
	int r = 0, neg = 1;
	char ch;
	do {
		ch = io.gc();
	} while (ch < 48 || ch > 57);
	do r = r * 10 + ch - 48, ch = io.gc(); while (ch >= 48 && ch <= 57);
	return r;
}
void write(int x) {
	if (x < 0) x = -x, io.pc('-');
	if (x >= 10) write(x / 10);
	io.pc(48 + x % 10);
}
void output(int x, char ch = ' ') {
	write(x);
	io.pc(ch);	
}
int main() {
	std::vector<int> useful_b;
	int m, n;
	double p;
	m = read(), p = read(), n = read();
	p /= 100;
	std::vector<int> h(n), table(m + 1);
	for (int i = 0; i < n; ++i)
		h[i] = read();
	for (int l = 1, r = 0; l <= m; l = r + 1) {
		r = m / (m / l);
		table[r] = true;
	}
	int sc = 0;
	double f = 1, g = 1;
	static std::pair<double, int> pos[1'000'005];
	static double a[1'000'005], b[1'000'005];
	auto ins = [&](double val, int b, int i) {
		int t = (m / b) * i;
		pos[t] = std::max(pos[t], std::make_pair(val, b));
	};
	double z = (1 - p) / p, z0 = p / (1 - p);
	for (int i = 1; i <= m; ++i) {
		double lim = i * p;
		if (sc < lim) {
			++sc;
			f = f - (1 - p) * g;
			g = g * lim / sc;
		}
		else {
			f = f + g * sc * (1 - p) / (i - sc);
			g = g * (1 - p) * i / (i - sc);
		}
		if (table[i]) {
			a[sc] = f, b[sc] = g;
			ins(f, i, sc);
			double *pa = a + sc, *pb = b + sc;
			for (int j = sc - 1; j >= 1; --j) {
				double bj = *pb * z * (j + 1) / (i - j);
				*--pb = bj;
				double aj = *pa + *pb;
				*--pa = aj;
				if (1 - *pb > eps) {
					ins(*pa, i, j);
				}
				else if (i == m) {
					ins(1, i, j);
				}
			}
			pa = a + sc, pb = b + sc;
			for (int j = sc + 1; j <= i; ++j) {
				double bj = *pb * z0 * (i - j + 1) / j;
				double aj = *pa - *pb;
				*++pb = bj;
				*++pa = aj;
				if (*pa >= p)
					ins(*pa, i, j);
			}
		}
	}
	for (int i = m; i > 0; --i)
		pos[i] = std::max(pos[i], pos[i + 1]);
	for (int i = 0; i < n; ++i) {
		int x = 0, y = 0;
		if (h[i] > m) {
			x = y = 1;
		}
		else {
			y = pos[h[i]].second;
			x = m / y;
		}
		output(x); output(y, '\n');
	}
}



详细

answer.code:55:44: warning: multi-character character constant [-Wmultichar]
   55 |         static std::pair<double, int> pos[1'000'005];
      |                                            ^~~~~
answer.code:56:26: warning: multi-character character constant [-Wmultichar]
   56 |         static double a[1'000'005], b[1'000'005];
      |                          ^~~~~
answer.code:56:40: warning: multi-character character constant [-Wmultichar]
   56 |         static double a[1'000'005], b[1'000'005];
      |                                        ^~~~~
answer.code: In function ‘int main()’:
answer.code:55:44: error: expected ‘]’ before '\x303030'
   55 |         static std::pair<double, int> pos[1'000'005];
      |                                            ^~~~~
      |                                            ]
answer.code:56:26: error: expected ‘]’ before '\x303030'
   56 |         static double a[1'000'005], b[1'000'005];
      |                          ^~~~~
      |                          ]
answer.code:57:14: error: ‘ins’ does not name a type; did you mean ‘int’?
   57 |         auto ins = [&](double val, int b, int i) {
      |              ^~~
      |              int
answer.code:74:25: error: ‘a’ was not declared in this scope
   74 |                         a[sc] = f, b[sc] = g;
      |                         ^
answer.code:74:36: error: ‘b’ was not declared in this scope
   74 |                         a[sc] = f, b[sc] = g;
      |                                    ^
answer.code:75:25: error: ‘ins’ was not declared in this scope; did you mean ‘int’?
   75 |                         ins(f, i, sc);
      |                         ^~~
      |                         int
answer.code:78:46: error: ‘pb’ was not declared in this scope; did you mean ‘pa’?
   78 |                                 double bj = *pb * z * (j + 1) / (i - j);
      |                                              ^~
      |                                              pa
answer.code:89:38: error: ‘pb’ was not declared in this scope; did you mean ‘pa’?
   89 |                         pa = a + sc, pb = b + sc;
      |                                      ^~
      |                                      pa
answer.code:101:17: error: ‘pos’ was not declared in this scope; did you mean ‘pow’?
  101 |                 pos[i] = std::max(pos[i], pos[i + 1]);
      |                 ^~~
      |                 pow
answer.code:108:29: error: ‘pos’ was not declared in this scope; did you mean ‘pow’?
  108 |                         y = pos[h[i]].second;
      |                             ^~~
      |                             pow
answer.code: In constructor ‘fast_io<T>::fast_io() [with int T = 2097152]’:
answer.code:9:22: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 fread(p, 1, T, stdin);
      |                 ~~~~~^~~~~~~~~~~~~~~~