QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#333267#7877. Balanced ArrayKazdaleCompile Error//C++141.6kb2024-02-19 19:22:202024-02-19 19:22:21

Judging History

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

  • [2024-02-19 19:22:21]
  • 评测
  • [2024-02-19 19:22:20]
  • 提交

answer

#include <iostream>
#define int long long
using namespace std;
constexpr int mod1(998244353);
constexpr int mod2(1000000007);
constexpr int mod3(917120411);
constexpr int MAXN(3000007);
string s;
int a[MAXN], hs1[MAXN], hs2[MAXN], d1[MAXN], d2[MAXN], ans[MAXN];
int n, misaki(1)
inline void read(int &temp) { cin >> temp; }
inline int val(int x) {
	if (x <= '9' && x >= '0')  return x - '0';
	if (x >= 'a' && x <= 'z')  return x - 'a' + 10;
	return x - 'A' + 36;
}
inline int calc(string s) {
	int res(0);
	for (int i(0); i < (int)s.length(); ++i)  res = res * 62ll + val(s[i]);
	return res;
}
inline int hsh(int l, int r, int *a, int *b, int c) 
	{ return (a[r] - a[l - 1] * b[r - l + 1] % c + c) % c; }
inline bool check(int x, int k, int *a, int *b, int c) 
	{ return (hsh(1, x - 2 * k, a, b, c) + hsh(1 + 2 * k, x, a, b, c)) % c == hsh(1 + k, x - k, a, b, c) * 2 % c; }
signed main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	read(n), d1[0] = d2[0] = 1;
	for (int i(1); i <= n; ++i)  cin >> s, a[i] = calc(s);
//	cout << endl;
	for (int i(1); i <= n; ++i)  hs1[i] = (hs1[i - 1] * mod3 + a[i]) % mod1, d1[i] = d1[i - 1] * mod3 % mod1;
	for (int i(1); i <= n; ++i)  hs2[i] = (hs2[i - 1] * mod3 + a[i]) % mod2, d2[i] = d2[i - 1] * mod3 % mod2;
	for (int k(1); k <= n; ++k) {
		while (misaki <= n && misaki <= 2 * k)  ++misaki;
		if (misaki > n)  break;
		while (misaki <= n && check(misaki, k, hs1, d1, mod1) && check(misaki, k, hs2, d2, mod2))  ans[misaki] = 1, ++misaki;
		if (misaki > n)  break;
	}
	for (int i(1); i <= n; ++i)  cout << ans[i];
	cout << endl;
	return 0;
}
/*
9
1C 3f 4S 3h 88 6x 4W d1 8c
*/

详细

answer.code:11:1: error: expected ‘,’ or ‘;’ before ‘inline’
   11 | inline void read(int &temp) { cin >> temp; }
      | ^~~~~~
answer.code: In function ‘int main()’:
answer.code:28:9: error: ‘read’ was not declared in this scope; did you mean ‘fread’?
   28 |         read(n), d1[0] = d2[0] = 1;
      |         ^~~~
      |         fread