QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#327283#7780. Dark LaTeX vs. Light LaTeXzhaohaikunCompile Error//C++202.9kb2024-02-14 21:18:042024-02-14 21:18:04

Judging History

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

  • [2024-11-25 20:53:52]
  • hack成功,自动添加数据
  • (/hack/1258)
  • [2024-02-14 21:18:04]
  • 评测
  • [2024-02-14 21:18:04]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T& x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
bool be;
const int N = 5010;
string s, t;
int lcpst1[N][N], lcpst2[N][N], sss[N][N], sst[N][N];
ll ans;
bool ed;
signed main() {
	cin.tie(0) -> sync_with_stdio(0);
	debug << (abs(&ed - &be)) / 1024 / 1024 << endl;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	s = ' ' + s, t = ' ' + t;
	DF(i, n, 1) {
		DF(j, m, 1) {
			if (s[i] == t[j]) lcpst1[i][j] = lcpst1[i + 1][j + 1] + 1;
		}
	}
	F(i, 1, n) {
		F(j, 1, m) {
			if (s[i] == t[j]) lcpst2[i][j] = lcpst2[i - 1][j - 1] + 1;
		}
	}
	// DF(i, n, 1) {
	// 	DF(j, n, 1) {
	// 		if (s[i] == s[j]) lcps[i][j] = lcps[i + 1][j + 1] + 1;
	// 	}
	// }
	// F(i, 1, m) {
	// 	F(j, 1, m) {
	// 		if (t[i] == t[j]) lcpt[i][j] = lcpt[i - 1][j - 1] + 1;
	// 	}
	// }
	F(i, 1, n) {
		F(j, 1, m) {
			sss[i][1]++;
			sss[i][lcpst2[i][j] + 1]--;
		}
		int cur = 0;
		F(j, 1, n) {
			cur += sss[i][j];
			sss[i][j] = sss[i][j - 1] + cur;
		}
		// debug << i << " " << occs[i][1] << endl;
		// debug << occs[i][2] << endl;
	}
	F(i, 1, m) {
		F(j, 1, n) {
			sst[i][1]++;
			// debug << j << " " << i << " " << lcpst[j][i] << endl;
			sst[i][lcpst1[j][i] + 1]--;
		}
		int cur = 0;
		F(j, 1, m) {
			cur += sst[i][j];
			sst[i][j] = sst[i][j - 1] + cur;
		}
		// debug << occt[i][1] << endl;
		// debug << occt[i][2] << endl;
	}
	ms(lcpst1, 0);
	ms(lcpst2, 0);
	DF(i, n, 1) {
		DF(j, n, 1) {
			if (s[i] == s[j]) lcpst1[i][j] = lcpst1[i + 1][j + 1] + 1;
		}
	}
	F(i, 1, m) {
		F(j, 1, m) {
			if (t[i] == t[j]) lcpst2[i][j] = lcpst2[i - 1][j - 1] + 1;
		}
	}
	F(i, 1, n)
		F(j, i, n) {
			int len = min(j - i, lcpst1[i][j + 1]);
			ans += sss[j][j - i + 1] - sss[j][j - i + 1 - len - 1];
			// debug << i << " " << j << " " << len << " " << ans << " " << j - i + 1 << endl;
		}
	// debug << ans << endl;
	F(i, 1, m)
		F(j, i, m) {
			int len = min(j - i, lcpst2[i - 1][j]);
			if (!len) continue;
			ans += sst[i][j - i] - sst[i][j - i + 1 - len - 1];
		}
	cout << ans;
	return 0;
}
/* why?
*/

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~