QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#308626#6181. 重复函数问题Cocoly1990Compile Error//C++142.3kb2024-01-20 11:14:522024-01-20 11:14:53

Judging History

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

  • [2024-01-20 11:14:53]
  • 评测
  • [2024-01-20 11:14:52]
  • 提交

answer

// Stop the noise and stop the clocks
// Problem: #P6067. 「FJOI2022」重复函数问题
// Contest: Hydro
// URL: http://10.110.182.1/p/P6067
// Time: 2024-01-20 10:06:09
// Memory Limit: 512 MB
// Author: Cocoly1990
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;

int n, z[N], nxt[N], ans[N], fa[N];
char s[N];
set<int> st;
vector<int> vec[N];

struct Fenwick_Tree {
	int t[N];
	
	void add (int x, int k) {
		if (! x) return;
		for (; x <= n; x += x & -x) t[x] += k;
	}
	
	void add (int l, int r, int k) {
		add (l, k);
		add (r + 1, -k);
	}
	
	int ask (int x) {
		int res = 0;
		for (; x; x -= x & -x) res += t[x];
		return res;
	}
} t;

signed main () {
	ios :: sync_with_stdio (false); cin.tie (0); cout.tie (0);
	cin >> (s + 1);
	n = strlen (s + 1);
	nxt[1] = 0;
	for (int i = 2, j = 0; i <= n; i ++) {
		while (j and s[j + 1] != s[i]) j = nxt[j];
		nxt[i] = (j += s[j + 1] == s[i]);
	}
	
	z[1] = n; 
	for (int i = 2, l = 0, r = 0; i <= n; i ++) {
		if (i <= r) z[i] = min(z[i - l + 1], r - i + 1);
		while (i + z[i] <= n and s[i + z[i]] == s[z[i] + 1]) z[i] ++;
		if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
	}
	
	for (int i = 1; i <= n; i ++) 
		vec[z[i]].push_back (i);
	
	t.add (1, n, n + 1);
	st.insert (0);
	st.insert (n + 1);
	// return 0;
	
	for (int k = nxt[n], lst = n + 1; k; k = nxt[k]) {
		// cout << k << "?\n";
		if (k * 2 > n) continue;
		for (int i = k; i < lst; i ++) {
			for (auto pos : vec[i]) {
				st.insert (pos);
				auto it = st.find (pos);
				int val = t.ask (pos);
				it = prev (it);
				int lst = *it + 1;
				t.add (lst, pos, -val);
				t.add (lst, pos, pos);
			}
		}
		// continue;
		lst = k;
		
		int x = 1, cnt = 0;
		for (; x <= n; ) {
			// if (k == 3) cout << x << "?\n";
			auto pos = t.ask (x);
			assert (pos >= x);
			if (pos == n + 1) break;
			cnt ++;
			x = pos + k;
		}
		
		// cout << cnt << " " << k << "?\n";
		
		ans[cnt] = max (ans[cnt], k);
	}
	
	for (int i = n; i; i --) ans[i] = max (ans[i], ans[i + 1]);
	for (int i = 2; i <= n; i ++) cout << ans[i] << " ";
}

詳細信息

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:14:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_Rb_tree_impl<std::less<int>, true>::~_Rb_tree_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<int>]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152:
/usr/include/c++/13/bits/stl_tree.h:662:16: note: called from here
  662 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~