QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555980#801. 回文自动机jayketCompile Error//C++232.4kb2024-09-10 13:20:582024-09-10 13:21:02

Judging History

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

  • [2024-09-10 13:21:02]
  • 评测
  • [2024-09-10 13:20:58]
  • 提交

answer

#include<bits/stdc++.h>

using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = long double;
using i128 = __int128_t;
using f128 = __float128;

#ifndef ONLINE_JUDGE
#include "algo\debug.hpp"
#else
#define debug(...) (void)42
#endif

template<class T>
constexpr void chmax(T& x, T y) {
	if (y > x) {
		x = y;
	}
}

template<class T>
constexpr void chmin(T& x, T y) {
	if (y < x) {
		x = y;
	}
}

struct PAM {
	static constexpr int ALPHABET = 26;
	static constexpr char OFFSET = 'a';
	struct Node {
		int len;
		int cnt;
		int suffixlink;
		std::array<int, ALPHABET>next;
		Node(): len{}, cnt{}, suffixlink{}, next{} {}
	};

	int suff;
	std::vector<Node>t;
	std::string s;

	PAM() {
		t.assign(2, Node());
		t[0].suffixlink = 1;
		t[1].suffixlink = 1;
		t[1].len = -1;
		suff = 0;
		s = "$";
	}

	int newNode() {
		t.emplace_back();
		return t.size() - 1;
	}

	int getfali(int u, int p) {
		while (p - t[u].len - 1 <= 0 or s[p - t[u].len - 1] != s[p]) {
			u = t[u].suffixlink;
		}
		return u;
	}

	void add(const char& c, int p) {
		s += c;
		int par = getfali(suff, p);
		if (not t[par].next[c - OFFSET]) {
			int cur = newNode();
			t[cur].suffixlink = t[getfali(t[par].suffixlink, p)].next[c - OFFSET];
			t[par].next[c - OFFSET] = cur;
			t[cur].len = t[par].len + 2;
			t[cur].cnt = t[t[cur].suffixlink].cnt + 1;
		}
		suff = t[par].next[c - OFFSET];
	}

	int size() {
		return t.size();
	}

	int next(int p, const char& c) {
		return t[p].next[c - OFFSET];
	}

	int link(int p) {
		return t[p].suffixlink;
	}

	int len(int p) {
		return t[p].len;
	}

	int cnt(int p) {
		return t[p].cnt;
	}
};

auto main() ->int32_t {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::string s;
	std::cin >> s;

	int n = s.size();
	PAM pam;
	std::vector<int>end;
	for (int i = 1; i <= n; i += 1) {
		pam.add(s[i - 1], i);
		end.push_back(pam.suff);
	}

	i64 ans = 0;
	std::vector adj(pam.size(), std::vector<int>());
	for (int i = 2; i < pam.size(); i += 1) {
		adj[pam.link(i)].push_back(i);
	}

	std::vector<int>f(pam.size());
	for (const auto & x : end) {
		f[x] += 1;
	}

	debug(end);
	debug(adj);

	auto dfs = [&](auto && dfs, int u) ->void {
		for (const auto & v : adj[u]) {
			dfs(dfs, v);
			f[u] += f[v];
		}
		ans = std::max(ans, 1LL * f[u] * pam.len(u) * pam.len(u));
	};
	dfs(dfs, 0);

	std::cout << ans << '\n';

	return 0;
}

詳細信息

answer.code: In lambda function:
answer.code:134:31: error: no matching function for call to ‘max(i64&, long long int)’
  134 |                 ans = std::max(ans, 1LL * f[u] * pam.len(u) * pam.len(u));
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:134:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
  134 |                 ans = std::max(ans, 1LL * f[u] * pam.len(u) * pam.len(u));
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:134:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
  134 |                 ans = std::max(ans, 1LL * f[u] * pam.len(u) * pam.len(u));
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:134:31: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
  134 |                 ans = std::max(ans, 1LL * f[u] * pam.len(u) * pam.len(u));
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:134:31: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
  134 |                 ans = std::max(ans, 1LL * f[u] * pam.len(u) * pam.len(u));
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~